Fail if somebody tries to write out a packet with an unsupported

encapsulation.

svn path=/trunk/; revision=39944
This commit is contained in:
Guy Harris 2011-11-18 21:39:18 +00:00
parent c95e2e88ce
commit 7694a8659d
1 changed files with 16 additions and 7 deletions

View File

@ -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 */