(/home/sate/Testcases/c/cve/wireshark-1.2.0/text2pcap.c) |
| |
| 1104 | | | parse_options (int argc, char *argv[]) |
| 1105 | | | { |
| 1106 | | | int c; |
| 1107 | | | char *p; |
| 1108 | | | |
| 1109 | | | |
| 1110 | | | while ((c = getopt(argc, argv, "dhqe:i:l:m:o:u:s:S:t:T:")) != -1) { |
Event 1:
Leaving loop. (c = getopt(...)) != -1 evaluates to false.
hide
|
|
| 1111 | | | switch(c) { |
| 1112 | | | case '?': usage(); break; |
| 1113 | | | case 'h': usage(); break; |
| 1114 | | | case 'd': if (!quiet) debug++; break; |
| 1115 | | | case 'q': quiet = TRUE; debug = FALSE; break; |
| 1116 | | | case 'l': pcap_link_type = strtol(optarg, NULL, 0); break; |
| 1117 | | | case 'm': max_offset = strtol(optarg, NULL, 0); break; |
| 1118 | | | case 'o': |
| 1119 | | | if (optarg[0]!='h' && optarg[0] != 'o' && optarg[0] != 'd') { |
| 1120 | | | fprintf(stderr, "Bad argument for '-o': %s\n", optarg); |
| 1121 1269 |  | | [ Lines 1121 to 1269 omitted. ] |
| 1270 | | | hdr_ip_proto = 6; |
| 1271 | | | hdr_ethernet = TRUE; |
| 1272 | | | hdr_ethernet_proto = 0x800; |
| 1273 | | | break; |
| 1274 | | | |
| 1275 | | | default: |
| 1276 | | | usage(); |
| 1277 | | | } |
| 1278 | | | } |
| 1279 | | | |
| 1280 | | | if (optind >= argc || argc-optind < 2) { |
Event 2:
Skipping " if". - optind >= argc evaluates to false.
- argc - optind < 2 evaluates to false.
hide
|
|
| 1281 | | | fprintf(stderr, "Must specify input and output filename\n"); |
| 1282 | | | usage(); |
| 1283 | | | } |
| 1284 | | | |
| 1285 | | | if (strcmp(argv[optind], "-")) { |
Event 3:
Taking true branch. strcmp(argv[optind], "-") evaluates to true.
hide
|
|
| 1286 | | | input_filename = g_strdup(argv[optind]); |
| 1287 | | | input_file = ws_fopen(input_filename, "rb"); |
| 1288 | | | if (!input_file) { |
Event 5:
Skipping " if". input_file evaluates to true.
hide
|
|
| 1289 | | | fprintf(stderr, "Cannot open file [%s] for reading: %s\n", |
| 1290 | | | input_filename, strerror(errno)); |
| 1291 | | | exit(-1); |
| 1292 | | | } |
| 1293 | | | } else { |
| 1294 | | | input_filename = "Standard input"; |
| 1295 | | | input_file = stdin; |
| 1296 | | | } |
| 1297 | | | |
| 1298 | | | if (strcmp(argv[optind+1], "-")) { |
Event 6:
Taking false branch. strcmp(argv[optind + 1], "-") evaluates to false.
hide
|
|
| 1299 | | | output_filename = g_strdup(argv[optind+1]); |
| 1300 | | | output_file = ws_fopen(output_filename, "wb"); |
| 1301 | | | if (!output_file) { |
| 1302 | | | fprintf(stderr, "Cannot open file [%s] for writing: %s\n", |
| 1303 | | | output_filename, strerror(errno)); |
| 1304 | | | exit(-1); |
| 1305 | | | } |
| 1306 | | | } else { |
| 1307 | | | output_filename = "Standard output"; |
| 1308 | | | output_file = stdout; |
| 1309 | | | } |
| 1310 | | | |
| 1311 | | | |
| 1312 | | | if (pcap_link_type != 1 && hdr_ethernet) { |
Event 7:
Skipping " if". pcap_link_type != 1 evaluates to false.
hide
|
|
| 1313 | | | fprintf(stderr, "Dummy (-e, -i, -u, -s, -S -T) cannot be specified with link type override (-l)\n"); |
| 1314 | | | exit(-1); |
| 1315 | | | } |
| 1316 | | | |
| 1317 | | | |
| 1318 | | | if (!input_file) { |
Event 8:
Skipping " if". input_file evaluates to true.
hide
|
|
| 1319 | | | input_file = stdin; |
| 1320 | | | input_filename = "Standard input"; |
| 1321 | | | } |
| 1322 | | | if (!output_file) { |
Event 9:
Skipping " if". output_file evaluates to true.
hide
|
|
| 1323 | | | output_file = stdout; |
| 1324 | | | output_filename = "Standard output"; |
| 1325 | | | } |
| 1326 | | | |
| 1327 | | | ts_sec = time(0); |
| 1328 | | | timecode_default = *localtime(&ts_sec); |
Event 10:
localtime() returns NULL. - Dereferenced later, causing the null pointer dereference.
hide
Null Pointer Dereference
localtime(&ts_sec) is dereferenced here, but it is NULL. The issue can occur if the highlighted code executes. See related event 10. Show: All events | Only primary events |
|
| |