diff options
author | Guy Harris <guy@alum.mit.edu> | 2011-11-18 21:39:18 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2011-11-18 21:39:18 +0000 |
commit | 7694a8659d46ce3483b745779baeccdf0a8c47fe (patch) | |
tree | 0b7f38f472b49874d577ee64cceb389ab0930736 /wiretap/k12text.l | |
parent | c95e2e88ceb9c8854b9791410debf56996255856 (diff) | |
download | wireshark-7694a8659d46ce3483b745779baeccdf0a8c47fe.tar.gz |
Fail if somebody tries to write out a packet with an unsupported
encapsulation.
svn path=/trunk/; revision=39944
Diffstat (limited to 'wiretap/k12text.l')
-rw-r--r-- | wiretap/k12text.l | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/wiretap/k12text.l b/wiretap/k12text.l index 541441556a..fae1d62350 100644 --- a/wiretap/k12text.l +++ b/wiretap/k12text.l @@ -337,7 +337,6 @@ static const struct { int e; const char* s; } encaps[] = { { WTAP_ENCAP_MTP3, "SSCF" }, { WTAP_ENCAP_CHDLC, "HDLC" }, /* ... */ - { WTAP_ENCAP_UNKNOWN, "UNKNOWN" }, { 0, NULL } }; @@ -350,23 +349,33 @@ k12text_dump(wtap_dumper *wdh _U_, const struct wtap_pkthdr *phdr, size_t left = K12BUF_SIZE; gint wl; char *p; - const char* str_enc = ""; + const char* str_enc; guint i; guint ns; guint ms; gboolean ret; + str_enc = NULL; + for(i=0; encaps[i].s; i++) { + if (phdr->pkt_encap == encaps[i].e) { + str_enc = encaps[i].s; + break; + } + } + if (str_enc == NULL) { + /* + * That encapsulation type is not supported. Fail. + */ + *err = WTAP_ERR_UNSUPPORTED_ENCAP; + return FALSE; + } + buf = g_malloc(K12BUF_SIZE); p = buf; ms = phdr->ts.nsecs / 1000000; ns = (phdr->ts.nsecs - (1000000*ms))/1000; - for(i=0; encaps[i].s; i++) { - str_enc = encaps[i].s; - if (phdr->pkt_encap == encaps[i].e) break; - } - #ifdef _MSC_VER /* calling gmtime() on MSVC 2005 with huge values causes it to crash */ /* XXX - find the exact value that still does work */ |