~ubuntu-branches/ubuntu/gutsy/wireshark/gutsy-security

« back to all changes in this revision

Viewing changes to wiretap/nettl.c

  • Committer: Bazaar Package Importer
  • Author(s): Frederic Peters
  • Date: 2007-04-01 08:58:40 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070401085840-or3qhrpv8alt1bwg
Tags: 0.99.5-1
* New upstream release.
* debian/patches/09_idl2wrs.dpatch: updated to patch idl2wrs.sh.in.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* nettl.c
2
2
 *
3
 
 * $Id: nettl.c 18945 2006-08-18 09:01:20Z guy $
 
3
 * $Id: nettl.c 20253 2007-01-01 14:48:18Z jake $
4
4
 *
5
5
 * Wiretap Library
6
6
 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
20
20
 *
21
21
 * You should have received a copy of the GNU General Public License
22
22
 * along with this program; if not, write to the Free Software
23
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
23
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24
24
 */
25
25
 
26
26
#ifdef HAVE_CONFIG_H
175
175
/* header is followed by data and once again the total length (2 bytes) ! */
176
176
 
177
177
static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
178
 
                long *data_offset);
179
 
static gboolean nettl_seek_read(wtap *wth, long seek_off,
 
178
                gint64 *data_offset);
 
179
static gboolean nettl_seek_read(wtap *wth, gint64 seek_off,
180
180
                union wtap_pseudo_header *pseudo_header, guchar *pd,
181
181
                int length, int *err, gchar **err_info);
182
182
static int nettl_read_rec_header(wtap *wth, FILE_T fh,
263
263
        case NETTL_SUBSYS_NS_LS_UDP :
264
264
        case NETTL_SUBSYS_NS_LS_IPV6 :
265
265
                wth->file_encap = WTAP_ENCAP_NETTL_RAW_IP;
 
266
                break;
266
267
        case NETTL_SUBSYS_NS_LS_ICMP :
267
268
                wth->file_encap = WTAP_ENCAP_NETTL_RAW_ICMP;
 
269
                break;
268
270
        case NETTL_SUBSYS_NS_LS_ICMPV6 :
269
271
                wth->file_encap = WTAP_ENCAP_NETTL_RAW_ICMPV6;
270
272
                break;
 
273
        case NETTL_SUBSYS_NS_LS_TELNET :
 
274
                wth->file_encap = WTAP_ENCAP_NETTL_RAW_TELNET;
 
275
                break;
271
276
        default:
272
277
                /* If this assumption is bad, the read will catch it */
273
278
                wth->file_encap = WTAP_ENCAP_NETTL_ETHERNET;
285
290
 
286
291
/* Read the next packet */
287
292
static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
288
 
    long *data_offset)
 
293
    gint64 *data_offset)
289
294
{
290
295
    int ret;
291
296
    gboolean fddihack=FALSE;
327
332
}
328
333
 
329
334
static gboolean
330
 
nettl_seek_read(wtap *wth, long seek_off,
 
335
nettl_seek_read(wtap *wth, gint64 seek_off,
331
336
                union wtap_pseudo_header *pseudo_header, guchar *pd,
332
337
                int length, int *err, gchar **err_info)
333
338
{
434
439
        case NETTL_SUBSYS_NS_LS_IPV6 :
435
440
        case NETTL_SUBSYS_NS_LS_ICMPV6 :
436
441
        case NETTL_SUBSYS_NS_LS_ICMP :
 
442
        case NETTL_SUBSYS_NS_LS_TELNET :
437
443
            if( (subsys == NETTL_SUBSYS_NS_LS_IP)
438
444
             || (subsys == NETTL_SUBSYS_NS_LS_LOOPBACK)
439
445
             || (subsys == NETTL_SUBSYS_NS_LS_UDP)
444
450
                phdr->pkt_encap = WTAP_ENCAP_NETTL_RAW_ICMP;
445
451
            } else if (subsys == NETTL_SUBSYS_NS_LS_ICMPV6) {
446
452
                phdr->pkt_encap = WTAP_ENCAP_NETTL_RAW_ICMPV6;
 
453
            } else if (subsys == NETTL_SUBSYS_NS_LS_TELNET) {
 
454
                phdr->pkt_encap = WTAP_ENCAP_NETTL_RAW_TELNET;
447
455
            } else if( (subsys == NETTL_SUBSYS_HPPB_FDDI)
448
456
                    || (subsys == NETTL_SUBSYS_EISA_FDDI)
449
457
                    || (subsys == NETTL_SUBSYS_PCI_FDDI)
571
579
            break;
572
580
    }
573
581
 
574
 
    if (length <= padlen) {
 
582
    if (length < padlen) {
575
583
        *err = WTAP_ERR_BAD_RECORD;
576
 
        *err_info = g_strdup_printf("nettl: packet length %u in record header too short, <= %u",
 
584
        *err_info = g_strdup_printf("nettl: packet length %u in record header too short, less than %u",
577
585
            length, padlen);
578
586
        return -1;
579
587
    }
580
588
    phdr->len = length - padlen;
581
 
    if (caplen <= padlen) {
 
589
    if (caplen < padlen) {
582
590
        *err = WTAP_ERR_BAD_RECORD;
583
 
        *err_info = g_strdup_printf("nettl: captured length %u in record header too short, <= %u",
 
591
        *err_info = g_strdup_printf("nettl: captured length %u in record header too short, less than %u",
584
592
            caplen, padlen);
585
593
        return -1;
586
594
    }
660
668
                case WTAP_ENCAP_NETTL_RAW_IP:
661
669
                case WTAP_ENCAP_NETTL_RAW_ICMP:
662
670
                case WTAP_ENCAP_NETTL_RAW_ICMPV6:
 
671
                case WTAP_ENCAP_NETTL_RAW_TELNET:
663
672
/*
664
673
                case WTAP_ENCAP_NETTL_X25:
665
674
*/
742
751
                case WTAP_ENCAP_NETTL_RAW_IP:
743
752
                case WTAP_ENCAP_NETTL_RAW_ICMP:
744
753
                case WTAP_ENCAP_NETTL_RAW_ICMPV6:
 
754
                case WTAP_ENCAP_NETTL_RAW_TELNET:
745
755
                case WTAP_ENCAP_NETTL_UNKNOWN:
746
756
                        rec_hdr.subsys = g_htons(pseudo_header->nettl.subsys);
747
757
                        rec_hdr.devid = g_htonl(pseudo_header->nettl.devid);