Be more picky about our sscanf integer field widths. Hopefully this will

help squelch Coverity CIDs 701-709.

svn path=/trunk/; revision=36511
This commit is contained in:
Gerald Combs 2011-04-07 23:16:05 +00:00
parent d00527f369
commit 56bc7f5e47
7 changed files with 12 additions and 12 deletions

View File

@ -380,11 +380,11 @@ parse_cosine_rec_hdr(wtap *wth, const char *line,
char if_name[COSINE_MAX_IF_NAME_LEN] = "", direction[6] = "";
struct tm tm;
if (sscanf(line, "%d-%d-%d,%d:%d:%d.%d:",
if (sscanf(line, "%4d-%2d-%2d,%2d:%2d:%2d.%9d:",
&yy, &mm, &dd, &hr, &min, &sec, &csec) == 7) {
/* appears to be output to a control blade */
num_items_scanned = sscanf(line,
"%d-%d-%d,%d:%d:%d.%d: %5s (%127[A-Za-z0-9/:]), Length:%d, Pro:%d, Off:%d, Pri:%d, RM:%d, Err:%d [%x, %x]",
"%4d-%2d-%2d,%2d:%2d:%2d.%9d: %5s (%127[A-Za-z0-9/:]), Length:%9d, Pro:%9d, Off:%9d, Pri:%9d, RM:%9d, Err:%9d [%8x, %8x]",
&yy, &mm, &dd, &hr, &min, &sec, &csec,
direction, if_name, &pkt_len,
&pro, &off, &pri, &rm, &error,
@ -398,7 +398,7 @@ parse_cosine_rec_hdr(wtap *wth, const char *line,
} else {
/* appears to be output to PE */
num_items_scanned = sscanf(line,
"%5s (%127[A-Za-z0-9/:]), Length:%d, Pro:%d, Off:%d, Pri:%d, RM:%d, Err:%d [%x, %x]",
"%5s (%127[A-Za-z0-9/:]), Length:%9d, Pro:%9d, Off:%9d, Pri:%9d, RM:%9d, Err:%9d [%8x, %8x]",
direction, if_name, &pkt_len,
&pro, &off, &pri, &rm, &error,
&code1, &code2);

View File

@ -153,7 +153,7 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info _U_, gint64 *data_offset
} while (readLine[0] == COMMENT_LINE);
/* parse one line of capture data */
if (sscanf(readLine, "%*s %" G_GINT64_MODIFIER "u.%d %u %" READDATA_MAX_FIELD_SIZE "s",
if (sscanf(readLine, "%*s %18" G_GINT64_MODIFIER "u.%9d %9u %" READDATA_MAX_FIELD_SIZE "s",
&seconds, &wth->phdr.ts.nsecs, &wth->phdr.len, readData) != 4) {
*err = WTAP_ERR_BAD_RECORD;
*err_info = g_strdup("daintree_sna: invalid read record");

View File

@ -394,7 +394,7 @@ parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, guint8* buf, int *err,
}
num_items_scanned = sscanf(line + LENGTH_POS,
"%d byte buffer at %d-%3s-%d %d:%d:%d.%d",
"%9d byte buffer at %2d-%3s-%4d %2d:%2d:%2d.%9d",
&pkt_len,
&tm.tm_mday, mon,
&tm.tm_year, &tm.tm_hour, &tm.tm_min,

View File

@ -317,7 +317,7 @@ iseries_check_file_type (wtap * wth, int *err, int format)
* extract it here and store for all packets to access
*/
num_items_scanned = sscanf (buf,
" START DATE/TIME . . . . . . : %d/%d/%d",
" START DATE/TIME . . . . . . : %2d/%2d/%4d",
&iseries->month, &iseries->day,
&iseries->year);
if (num_items_scanned == 3)
@ -527,7 +527,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh,
}
num_items_scanned =
sscanf (data,
"%6d %1s %6d %d:%d:%d.%d %12s %12s ETHV2 Type: %4s",
"%6d %1s %6d %2d:%2d:%2d.%9d %12s %12s ETHV2 Type: %4s",
&pktnum, direction, &cap_len, &hr, &min, &sec, &csec, destmac,
srcmac, type);
if (num_items_scanned == 10)

View File

@ -356,7 +356,7 @@ parse_netscreen_rec_hdr(wtap *wth, const char *line, char *cap_int,
char direction[2];
char cap_src[13];
if (sscanf(line, "%d.%d: %15[a-z0-9/:.](%1[io]) len=%d:%12s->%12s/",
if (sscanf(line, "%9d.%9d: %15[a-z0-9/:.](%1[io]) len=%9d:%12s->%12s/",
&sec, &dsec, cap_int, direction, &pkt_len, cap_src, cap_dst) < 5) {
*err = WTAP_ERR_BAD_RECORD;
*err_info = g_strdup("netscreen: Can't parse packet-header");

View File

@ -314,7 +314,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
/* Find text in line after "[No.". Limit the length of the
* two strings since we have fixed buffers for channel[] and
* direction[] */
num_items_scanned = sscanf(line, "%d] %d:%d:%d.%d %9s %9s",
num_items_scanned = sscanf(line, "%9d] %2d:%2d:%2d.%9d %9s %9s",
&pktnum, &hr, &min, &sec, &csec, channel, direction);
if (num_items_scanned != 7) {
@ -346,7 +346,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE_T fh,
} while (strcmp(line, "OFFSET 0001-0203") != 0);
num_items_scanned = sscanf(line+64, "LEN=%d", &pkt_len);
num_items_scanned = sscanf(line+64, "LEN=%9d", &pkt_len);
if (num_items_scanned != 1) {
*err = WTAP_ERR_BAD_RECORD;
*err_info = g_strdup("toshiba: OFFSET line doesn't have valid LEN item");

View File

@ -400,14 +400,14 @@ parse_vms_rec_hdr(wtap *wth, FILE_T fh, int *err, gchar **err_info)
/* First look for the Format 1 type sequencing */
num_items_scanned = sscanf(p,
"packet %d at %d-%3s-%d %d:%d:%d.%d",
"packet %9d at %2d-%3s-%4d %2d:%2d:%2d.%9d",
&pktnum, &tm.tm_mday, mon,
&tm.tm_year, &tm.tm_hour,
&tm.tm_min, &tm.tm_sec, &csec);
/* Next look for the Format 2 type sequencing */
if (num_items_scanned != 8) {
num_items_scanned = sscanf(p,
"packet seq # = %d at %d-%3s-%d %d:%d:%d.%d",
"packet seq # = %9d at %2d-%3s-%4d %2d:%2d:%2d.%9d",
&pktnum, &tm.tm_mday, mon,
&tm.tm_year, &tm.tm_hour,
&tm.tm_min, &tm.tm_sec, &csec);