wireshark/wiretap/netscreen.h
Guy Harris 6a140eca7b Fix packet length handling.
Treat the packet length as unsigned - it shouldn't be negative in the
file.  If it is, that'll probably cause the sscanf to fail, so we'll
report the file as bad.

Check it against WTAP_MAX_PACKET_SIZE to make sure we don't try to
allocate a huge amount of memory, just as we do in other file readers.

Use the now-validated packet size as the length in
ws_buffer_assure_space(), so we are certain to have enough space, and
don't allocate too much space.

Merge the header and packet data parsing routines while we're at it.

Bug: 12396
Change-Id: I7f981f9cdcbea7ecdeb88bfff2f12d875de2244f
Reviewed-on: https://code.wireshark.org/review/15176
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-04-30 00:08:48 +00:00

52 lines
1.7 KiB
C

/* netscreen.h
*
* Juniper NetScreen snoop output parser
* Created by re-using a lot of code from cosine.c
* Copyright (c) 2007 by Sake Blok <sake@euronet.nl>
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef __W_NETSCREEN_H__
#define __W_NETSCREEN_H__
#include <glib.h>
#include "wtap.h"
/* Magic text to check for NetScreen snoop output */
#define NETSCREEN_HDR_MAGIC_STR1 "(i) len="
#define NETSCREEN_HDR_MAGIC_STR2 "(o) len="
/* Magic text for start of packet */
#define NETSCREEN_REC_MAGIC_STR1 NETSCREEN_HDR_MAGIC_STR1
#define NETSCREEN_REC_MAGIC_STR2 NETSCREEN_HDR_MAGIC_STR2
#define NETSCREEN_LINE_LENGTH 128
#define NETSCREEN_HEADER_LINES_TO_CHECK 32
#define NETSCREEN_MAX_INFOLINES 8
#define NETSCREEN_SPACES_ON_INFO_LINE 14
#define NETSCREEN_MAX_INT_NAME_LENGTH 16
#define NETSCREEN_INGRESS FALSE
#define NETSCREEN_EGRESS TRUE
wtap_open_return_val netscreen_open(wtap *wth, int *err, gchar **err_info);
#endif