(/home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/rtp_analysis.c) |
| |
| 2248 | | | static gboolean copy_file(gchar *dest, gint channels, gint format, user_data_t *user_data) |
| 2249 | | | { |
| 2250 | | | FILE *to_stream, *forw_stream, *rev_stream; |
| 2251 | | | size_t fwritten, rwritten; |
| 2252 | | | int f_rawvalue, r_rawvalue, rawvalue; |
| 2253 | | | gint16 sample; |
| 2254 | | | gchar pd[4]; |
| 2255 | | | guint32 f_write_silence = 0; |
| 2256 | | | guint32 r_write_silence = 0; |
| 2257 | | | progdlg_t *progbar; |
| 2258 | | | guint32 progbar_count, progbar_quantum, progbar_nextstep = 0, count = 0; |
| 2259 | | | gboolean stop_flag = FALSE; |
| 2260 | | | size_t nchars; |
| 2261 | | | |
| 2262 | | | forw_stream = ws_fopen(user_data->f_tempname, "rb"); |
| 2263 | | | if (forw_stream == NULL) |
| 2264 | | | return FALSE; |
| 2265 | | | rev_stream = ws_fopen(user_data->r_tempname, "rb"); |
| 2266 | | | if (rev_stream == NULL) { |
| 2267 | | | fclose(forw_stream); |
| 2268 | | | return FALSE; |
| 2269 | | | } |
| 2270 | | | |
| 2271 | | | |
| 2272 | | | to_stream = ws_fopen(dest, "wb"); |
| 2273 | | | if (to_stream == NULL) { |
| 2274 | | | fclose(forw_stream); |
| 2275 | | | fclose(rev_stream); |
| 2276 | | | return FALSE; |
| 2277 | | | } |
| 2278 | | | |
| 2279 | | | progbar = create_progress_dlg("Saving voice in a file", dest, TRUE, &stop_flag); |
| 2280 | | | |
| 2281 | | | if (format == SAVE_AU_FORMAT) |
| 2282 | | | { |
| 2283 | | | |
| 2284 | | | |
| 2285 | | | phtonl(pd, 0x2e736e64);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
90 | #define phtonl(p, v) \ |
91 | { \ |
92 | ((guint8*)(p))[0] = (guint8)((v) >> 24); \ |
93 | ((guint8*)(p))[1] = (guint8)((v) >> 16); \ |
94 | ((guint8*)(p))[2] = (guint8)((v) >> 8); \ |
95 | ((guint8*)(p))[3] = (guint8)((v) >> 0); \ |
96 | } |
| |
|
| 2286 | | | nchars=fwrite(pd, 1, 4, to_stream); |
| 2287 | | | |
| 2288 | | | phtonl(pd, 24);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
90 | #define phtonl(p, v) \ |
91 | { \ |
92 | ((guint8*)(p))[0] = (guint8)((v) >> 24); \ |
93 | ((guint8*)(p))[1] = (guint8)((v) >> 16); \ |
94 | ((guint8*)(p))[2] = (guint8)((v) >> 8); \ |
95 | ((guint8*)(p))[3] = (guint8)((v) >> 0); \ |
96 | } |
| |
|
| 2289 | | | nchars=fwrite(pd, 1, 4, to_stream); |
| 2290 | | | |
| 2291 | | | phtonl(pd, -1);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
90 | #define phtonl(p, v) \ |
91 | { \ |
92 | ((guint8*)(p))[0] = (guint8)((v) >> 24); \ |
93 | ((guint8*)(p))[1] = (guint8)((v) >> 16); \ |
94 | ((guint8*)(p))[2] = (guint8)((v) >> 8); \ |
95 | ((guint8*)(p))[3] = (guint8)((v) >> 0); \ |
96 | } |
| |
|
| 2292 | | | nchars=fwrite(pd, 1, 4, to_stream); |
| 2293 | | | |
| 2294 | | | phtonl(pd, 3);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
90 | #define phtonl(p, v) \ |
91 | { \ |
92 | ((guint8*)(p))[0] = (guint8)((v) >> 24); \ |
93 | ((guint8*)(p))[1] = (guint8)((v) >> 16); \ |
94 | ((guint8*)(p))[2] = (guint8)((v) >> 8); \ |
95 | ((guint8*)(p))[3] = (guint8)((v) >> 0); \ |
96 | } |
| |
|
| 2295 | | | nchars=fwrite(pd, 1, 4, to_stream); |
| 2296 | | | |
| 2297 | | | phtonl(pd, 8000);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
90 | #define phtonl(p, v) \ |
91 | { \ |
92 | ((guint8*)(p))[0] = (guint8)((v) >> 24); \ |
93 | ((guint8*)(p))[1] = (guint8)((v) >> 16); \ |
94 | ((guint8*)(p))[2] = (guint8)((v) >> 8); \ |
95 | ((guint8*)(p))[3] = (guint8)((v) >> 0); \ |
96 | } |
| |
|
| 2298 | | | nchars=fwrite(pd, 1, 4, to_stream); |
| 2299 | | | |
| 2300 | | | phtonl(pd, 1);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
90 | #define phtonl(p, v) \ |
91 | { \ |
92 | ((guint8*)(p))[0] = (guint8)((v) >> 24); \ |
93 | ((guint8*)(p))[1] = (guint8)((v) >> 16); \ |
94 | ((guint8*)(p))[2] = (guint8)((v) >> 8); \ |
95 | ((guint8*)(p))[3] = (guint8)((v) >> 0); \ |
96 | } |
| |
|
| 2301 | | | nchars=fwrite(pd, 1, 4, to_stream); |
| 2302 | | | |
| 2303 | | | |
| 2304 | | | switch (channels) { |
| 2305 | | | |
| 2306 | | | case SAVE_FORWARD_DIRECTION_MASK: { |
| 2307 | | | progbar_count = user_data->forward.saveinfo.count; |
| 2308 | | | progbar_quantum = user_data->forward.saveinfo.count/100; |
| 2309 | | | while ((f_rawvalue = getc(forw_stream)) != EOF) { |
| 2310 | | | if(stop_flag) |
| 2311 | | | break; |
| 2312 | | | if((count > progbar_nextstep) && (count <= progbar_count)) { |
| 2313 | | | update_progress_dlg(progbar, |
| 2314 | | | (gfloat) count/progbar_count, "Saving"); |
| 2315 | | | progbar_nextstep = progbar_nextstep + progbar_quantum; |
| 2316 | | | } |
| 2317 | | | count++; |
| 2318 | | | |
| 2319 | | | if (user_data->forward.statinfo.pt == PT_PCMU){ |
| 2320 | | | sample = ulaw2linear((unsigned char)f_rawvalue); |
| 2321 | | | phtons(pd, sample);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
84 | #define phtons(p, v) \ |
85 | { \ |
86 | ((guint8*)(p))[0] = (guint8)((v) >> 8); \ |
87 | ((guint8*)(p))[1] = (guint8)((v) >> 0); \ |
88 | } |
| |
|
| 2322 | | | } |
| 2323 | | | else if(user_data->forward.statinfo.pt == PT_PCMA){ |
| 2324 | | | sample = alaw2linear((unsigned char)f_rawvalue); |
| 2325 | | | phtons(pd, sample);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
84 | #define phtons(p, v) \ |
85 | { \ |
86 | ((guint8*)(p))[0] = (guint8)((v) >> 8); \ |
87 | ((guint8*)(p))[1] = (guint8)((v) >> 0); \ |
88 | } |
| |
|
| 2326 | | | } |
| 2327 | | | else{ |
| 2328 | | | fclose(forw_stream); |
| 2329 | | | fclose(rev_stream); |
| 2330 | | | fclose(to_stream); |
| 2331 | | | destroy_progress_dlg(progbar); |
| 2332 | | | return FALSE; |
| 2333 | | | } |
| 2334 | | | |
| 2335 | | | fwritten = fwrite(pd, 1, 2, to_stream); |
| 2336 | | | if (fwritten < 2) { |
| 2337 | | | fclose(forw_stream); |
| 2338 | | | fclose(rev_stream); |
| 2339 | | | fclose(to_stream); |
| 2340 | | | destroy_progress_dlg(progbar); |
| 2341 | | | return FALSE; |
| 2342 | | | } |
| 2343 | | | } |
| 2344 | | | break; |
| 2345 | | | } |
| 2346 | | | |
| 2347 | | | case SAVE_REVERSE_DIRECTION_MASK: { |
| 2348 | | | progbar_count = user_data->reversed.saveinfo.count; |
| 2349 | | | progbar_quantum = user_data->reversed.saveinfo.count/100; |
| 2350 | | | while ((r_rawvalue = getc(rev_stream)) != EOF) { |
| 2351 | | | if(stop_flag) |
| 2352 | | | break; |
| 2353 | | | if((count > progbar_nextstep) && (count <= progbar_count)) { |
| 2354 | | | update_progress_dlg(progbar, |
| 2355 | | | (gfloat) count/progbar_count, "Saving"); |
| 2356 | | | progbar_nextstep = progbar_nextstep + progbar_quantum; |
| 2357 | | | } |
| 2358 | | | count++; |
| 2359 | | | |
| 2360 | | | if (user_data->reversed.statinfo.pt == PT_PCMU){ |
| 2361 | | | sample = ulaw2linear((unsigned char)r_rawvalue); |
| 2362 | | | phtons(pd, sample);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
84 | #define phtons(p, v) \ |
85 | { \ |
86 | ((guint8*)(p))[0] = (guint8)((v) >> 8); \ |
87 | ((guint8*)(p))[1] = (guint8)((v) >> 0); \ |
88 | } |
| |
|
| 2363 | | | } |
| 2364 | | | else if(user_data->reversed.statinfo.pt == PT_PCMA){ |
| 2365 | | | sample = alaw2linear((unsigned char)r_rawvalue); |
| 2366 | | | phtons(pd, sample);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
84 | #define phtons(p, v) \ |
85 | { \ |
86 | ((guint8*)(p))[0] = (guint8)((v) >> 8); \ |
87 | ((guint8*)(p))[1] = (guint8)((v) >> 0); \ |
88 | } |
| |
|
| 2367 | | | } |
| 2368 | | | else{ |
| 2369 | | | fclose(forw_stream); |
| 2370 | | | fclose(rev_stream); |
| 2371 | | | fclose(to_stream); |
| 2372 | | | destroy_progress_dlg(progbar); |
| 2373 | | | return FALSE; |
| 2374 | | | } |
| 2375 | | | |
| 2376 | | | rwritten = fwrite(pd, 1, 2, to_stream); |
| 2377 | | | if (rwritten < 2) { |
| 2378 | | | fclose(forw_stream); |
| 2379 | | | fclose(rev_stream); |
| 2380 | | | fclose(to_stream); |
| 2381 | | | destroy_progress_dlg(progbar); |
| 2382 | | | return FALSE; |
| 2383 | | | } |
| 2384 | | | } |
| 2385 | | | break; |
| 2386 | | | } |
| 2387 | | | |
| 2388 | | | case SAVE_BOTH_DIRECTION_MASK: {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/gtk/rtp_analysis.c |
| |
259 | #define SAVE_BOTH_DIRECTION_MASK (SAVE_FORWARD_DIRECTION_MASK|SAVE_REVERSE_DIRECTION_MASK) |
| |
|
| 2389 | | | (user_data->forward.saveinfo.count > user_data->reversed.saveinfo.count) ? |
| 2390 | | | (progbar_count = user_data->forward.saveinfo.count) : |
| 2391 | | | (progbar_count = user_data->reversed.saveinfo.count); |
| 2392 | | | progbar_quantum = progbar_count/100; |
| 2393 | | | |
| 2394 | | | |
| 2395 | | | if (user_data->forward.statinfo.start_time > user_data->reversed.statinfo.start_time) { |
| 2396 | | | f_write_silence = (guint32) |
| 2397 | | | ((user_data->forward.statinfo.start_time-user_data->reversed.statinfo.start_time)*8000); |
| 2398 | | | } |
| 2399 | | | else if (user_data->forward.statinfo.start_time < user_data->reversed.statinfo.start_time) { |
| 2400 | | | r_write_silence = (guint32) |
| 2401 | | | ((user_data->reversed.statinfo.start_time-user_data->forward.statinfo.start_time)*8000); |
| 2402 | | | } |
| 2403 | | | for(;;) { |
| 2404 | | | if(stop_flag) |
| 2405 | | | break; |
| 2406 | | | if((count > progbar_nextstep) && (count <= progbar_count)) { |
| 2407 | | | update_progress_dlg(progbar, |
| 2408 | | | (gfloat) count/progbar_count, "Saving"); |
| 2409 | | | progbar_nextstep = progbar_nextstep + progbar_quantum; |
| 2410 | | | } |
| 2411 | | | count++; |
| 2412 | | | if(f_write_silence > 0) { |
| 2413 | | | r_rawvalue = getc(rev_stream); |
| 2414 | | | switch (user_data->forward.statinfo.reg_pt) { |
| 2415 | | | case PT_PCMU: |
| 2416 | | | f_rawvalue = SILENCE_PCMU; |
| 2417 | | | break; |
| 2418 | | | case PT_PCMA: |
| 2419 | | | f_rawvalue = SILENCE_PCMA; |
| 2420 | | | break; |
| 2421 | | | default: |
| 2422 | | | f_rawvalue = 0; |
| 2423 | | | break; |
| 2424 | | | } |
| 2425 | | | f_write_silence--; |
| 2426 | | | } |
| 2427 | | | else if(r_write_silence > 0) { |
| 2428 | | | f_rawvalue = getc(forw_stream); |
| 2429 | | | switch (user_data->reversed.statinfo.reg_pt) { |
| 2430 | | | case PT_PCMU: |
| 2431 | | | r_rawvalue = SILENCE_PCMU; |
| 2432 | | | break; |
| 2433 | | | case PT_PCMA: |
| 2434 | | | r_rawvalue = SILENCE_PCMA; |
| 2435 | | | break; |
| 2436 | | | default: |
| 2437 | | | r_rawvalue = 0; |
| 2438 | | | break; |
| 2439 | | | } |
| 2440 | | | r_write_silence--; |
| 2441 | | | } |
| 2442 | | | else { |
| 2443 | | | f_rawvalue = getc(forw_stream); |
Ignored Return Value
The return value of getc() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- CodeSonar is configured to enforce Ignored Return Value checks for getc(). (To change the set of enforced Ignored Return Value checks, use configuration file parameters RETURN_CHECKER_CHECKED_FUNCS and RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 2444 | | | r_rawvalue = getc(rev_stream); |
| 2445 | | | } |
| 2446 | | | if ((r_rawvalue == EOF) && (f_rawvalue == EOF)) |
Event 2:
Skipping " if". r_rawvalue == -1 evaluates to false.
hide
|
|
| 2447 | | | break; |
| 2448 | | | if ((user_data->forward.statinfo.pt == PT_PCMU) && (user_data->reversed.statinfo.pt == PT_PCMU)){ |
Event 3:
Taking false branch. user_data->forward.statinfo.pt == 0 evaluates to false.
hide
|
|
| 2449 | | | sample = (ulaw2linear((unsigned char)r_rawvalue) + ulaw2linear((unsigned char)f_rawvalue)) / 2; |
| 2450 | | | phtons(pd, sample);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
84 | #define phtons(p, v) \ |
85 | { \ |
86 | ((guint8*)(p))[0] = (guint8)((v) >> 8); \ |
87 | ((guint8*)(p))[1] = (guint8)((v) >> 0); \ |
88 | } |
| |
|
| 2451 | | | } |
| 2452 | | | else if((user_data->forward.statinfo.pt == PT_PCMA) && (user_data->reversed.statinfo.pt == PT_PCMA)){ |
Event 4:
Taking false branch. user_data->forward.statinfo.pt == 8 evaluates to false.
hide
|
|
| 2453 | | | sample = (alaw2linear((unsigned char)r_rawvalue) + alaw2linear((unsigned char)f_rawvalue)) / 2; |
| 2454 | | | phtons(pd, sample);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/pint.h |
| |
84 | #define phtons(p, v) \ |
85 | { \ |
86 | ((guint8*)(p))[0] = (guint8)((v) >> 8); \ |
87 | ((guint8*)(p))[1] = (guint8)((v) >> 0); \ |
88 | } |
| |
|
| 2455 | | | } |
| 2456 | | | else |
| 2457 | | | { |
| 2458 | | | fclose(forw_stream); |
| 2459 | | | fclose(rev_stream); |
| 2460 | | | fclose(to_stream); |
| 2461 | | | destroy_progress_dlg(progbar); |
| 2462 | | | return FALSE; |
| 2463 | | | } |
| 2464 | | | |
| 2465 | | | |
| 2466 | | | rwritten = fwrite(pd, 1, 2, to_stream); |
| 2467 | | | if (rwritten < 2) { |
| 2468 | | | fclose(forw_stream); |
| 2469 | | | fclose(rev_stream); |
| 2470 | | | fclose(to_stream); |
| 2471 | | | destroy_progress_dlg(progbar); |
| 2472 | | | return FALSE; |
| 2473 | | | } |
| 2474 | | | } |
| 2475 | | | } |
| 2476 | | | } |
| 2477 | | | } |
| 2478 | | | else if (format == SAVE_RAW_FORMAT) |
| 2479 | | | { |
| 2480 | | | FILE *stream; |
| 2481 | | | switch (channels) { |
| 2482 | | | |
| 2483 | | | case SAVE_FORWARD_DIRECTION_MASK: { |
| 2484 | | | progbar_count = user_data->forward.saveinfo.count; |
| 2485 | | | progbar_quantum = user_data->forward.saveinfo.count/100; |
| 2486 | | | stream = forw_stream; |
| 2487 | | | break; |
| 2488 | | | } |
| 2489 | | | |
| 2490 | | | case SAVE_REVERSE_DIRECTION_MASK: { |
| 2491 | | | progbar_count = user_data->reversed.saveinfo.count; |
| 2492 | | | progbar_quantum = user_data->reversed.saveinfo.count/100; |
| 2493 | | | stream = rev_stream; |
| 2494 | | | break; |
| 2495 | | | } |
| 2496 | | | default: { |
| 2497 | | | fclose(forw_stream); |
| 2498 | | | fclose(rev_stream); |
| 2499 | | | fclose(to_stream); |
| 2500 | | | destroy_progress_dlg(progbar); |
| 2501 | | | return FALSE; |
| 2502 | | | } |
| 2503 | | | } |
| 2504 | | | |
| 2505 | | | |
| 2506 | | | |
| 2507 | | | |
| 2508 | | | while ((rawvalue = getc(stream)) != EOF) { |
| 2509 | | | if(stop_flag) |
| 2510 | | | break; |
| 2511 | | | if((count > progbar_nextstep) && (count <= progbar_count)) { |
| 2512 | | | update_progress_dlg(progbar, |
| 2513 | | | (gfloat) count/progbar_count, "Saving"); |
| 2514 | | | progbar_nextstep = progbar_nextstep + progbar_quantum; |
| 2515 | | | } |
| 2516 | | | count++; |
| 2517 | | | |
| 2518 | | | if (putc(rawvalue, to_stream) == EOF) { |
| 2519 | | | fclose(forw_stream); |
| 2520 | | | fclose(rev_stream); |
| 2521 | | | fclose(to_stream); |
| 2522 | | | destroy_progress_dlg(progbar); |
| 2523 | | | return FALSE; |
| 2524 | | | } |
| 2525 | | | } |
| 2526 | | | } |
| 2527 | | | |
| 2528 | | | destroy_progress_dlg(progbar); |
| 2529 | | | fclose(forw_stream); |
| 2530 | | | fclose(rev_stream); |
| 2531 | | | fclose(to_stream); |
| 2532 | | | return TRUE; |
| 2533 | | | } |
| |