diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-04-28 03:07:04 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-04-28 03:07:04 +0000 |
commit | a59e93173383caae98f7b660ac7b9327af03feca (patch) | |
tree | 33ee0d6b59e493abea2c98336e1c73a06969ec32 /wiretap | |
parent | faa13e5072bfb826c9d0756e521e011ecfdc4524 (diff) |
If xml_get_int() fails, bail immediately; don't use the variable it
would have filled in had it not failed. (Thanks and a tip of the Hatlo
hat to the Clang static analyzer for complaining about this.)
svn path=/trunk/; revision=42306
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/dct3trace.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c index f3a6169abd..dfc916994a 100644 --- a/wiretap/dct3trace.c +++ b/wiretap/dct3trace.c @@ -248,34 +248,33 @@ static gboolean dct3trace_get_packet(FILE_T fh, union wtap_pseudo_header *pseudo else if( memcmp(dct3trace_magic_record_start, line, strlen(dct3trace_magic_record_start)) == 0 ) { /* Parse L1 header <l1 ...>*/ - int channel, tmp, ret = 0; + int channel, tmp; char *ptr; pseudo_header->gsm_um.uplink = !strstr(line, "direction=\"down\""); - ret |= xml_get_int(&channel, line, "logicalchannel"); + if (xml_get_int(&channel, line, "logicalchannel") != 0) + goto baddata; /* Parse downlink only fields */ if( !pseudo_header->gsm_um.uplink ) { - ret |= xml_get_int(&tmp, line, "physicalchannel"); + if (xml_get_int(&tmp, line, "physicalchannel") != 0) + goto baddata; pseudo_header->gsm_um.arfcn = tmp; - ret |= xml_get_int(&tmp, line, "sequence"); + if (xml_get_int(&tmp, line, "sequence") != 0) + goto baddata; pseudo_header->gsm_um.tdma_frame = tmp; - ret |= xml_get_int(&tmp, line, "bsic"); + if (xml_get_int(&tmp, line, "bsic") != 0) + goto baddata; pseudo_header->gsm_um.bsic = tmp; - ret |= xml_get_int(&tmp, line, "error"); + if (xml_get_int(&tmp, line, "error") != 0) + goto baddata; pseudo_header->gsm_um.error = tmp; - ret |= xml_get_int(&tmp, line, "timeshift"); + if (xml_get_int(&tmp, line, "timeshift") != 0) + goto baddata; pseudo_header->gsm_um.timeshift = tmp; } - if( ret != 0 ) - { - *err = WTAP_ERR_BAD_FILE; - *err_info = g_strdup_printf("dct3trace: record missing mandatory attributes"); - return FALSE; - } - switch( channel ) { case 128: pseudo_header->gsm_um.channel = GSM_UM_CHANNEL_SDCCH; break; @@ -335,6 +334,11 @@ static gboolean dct3trace_get_packet(FILE_T fh, union wtap_pseudo_header *pseudo *err = WTAP_ERR_SHORT_READ; } return FALSE; + +baddata: + *err = WTAP_ERR_BAD_FILE; + *err_info = g_strdup_printf("dct3trace: record missing mandatory attributes"); + return FALSE; } |