Also, since Unix systems
treat network sockets as file descriptors, it is not uncommon to see file input functions
(rather than the network-oriented functions) used to read network data. Finally, it
is entirely possible to create duplicate copies of file/socket socket descriptors using the
dup() or dup2() function.
NOTE In C/C++ programs, file descriptors 0, 1, and 2 correspond to the
standard input (stdin), standard output (stdout), and standard error (stderr)
devices. The dup2() function can be used to make stdin become a copy of any
other file descriptor, including network sockets. Once this has been done, a
program no longer accepts keyboard input; instead, input is taken directly from the network
socket.
If this has been done, you might observe getchar() or gets() being used to read
incoming network data. Several of the source code scanners take command-line options
that will cause them to list all functions (such as those noted previously) in the program
that take external input. Running ITS4 in this fashion against find.c yields the following:
# ./its4 -m -v vulns.i4d find.c
find.c:482: read
find.c:526: read
Be careful not to introduce a buffer overflow when using in a loop.
Make sure to check your buffer boundaries.
Pages:
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515