Hi, patch comitted to SVN.
Thanks! On 11.09.2012, at 19:06, Rudy Matela <[email protected]> wrote: > Hello, > > There is a bug on fakesmsc. It gives segmentation fault when the > program reaches EOF. The simplest way to simulate the bug is: > > $ ./test/fakesmsc < /dev/null > 2012-09-11 13:56:02 [5946] [0] INFO: Debug_lvl = -1, log_file = > <none>, log_lvl = 0 > 2012-09-11 13:56:02 [5946] [0] INFO: Entering interactive mode. Type > your message on the command line > 2012-09-11 13:56:02 [5946] [0] INFO: fakesmsc starting > 2012-09-11 13:56:02 [5946] [0] DEBUG: Connecting to <127.0.0.1> > 2012-09-11 13:56:02 [5946] [0] PANIC: ./test/fakesmsc() [0x805d5ad] > 2012-09-11 13:56:02 [5946] [0] PANIC: > linux-gate.so.1(__kernel_rt_sigreturn+0) [0xb772140c] > 2012-09-11 13:56:02 [5946] [0] PANIC: ./test/fakesmsc(main+0x8a8) [0x804fc48] > 2012-09-11 13:56:02 [5946] [0] PANIC: > /usr/lib/libc.so.6(__libc_start_main+0xf5) [0xb7149605] > 2012-09-11 13:56:02 [5946] [0] PANIC: ./test/fakesmsc() [0x804fdd9] > Segmentation fault > > Real situations for it to happen include reading several messages from a file > $ ./test/fakesmsc < file.txt (after reaching the end of file the > program will crash) > > Or even reading from keyboard by simulating EOF when typing control+d. > > > Attached is a patch that solves the issue. The program now quits when > reaches end of file on stdin. This provides a great way to quit when > in interactive mode: type your messages, then ctrl+d to quit (as it is > on bash / python / perl / ruby and other interpreters). > > I've successfully applied it against revision 4995 using "patch -p0 < > fakesmsc-gracefully-quits-when-eof.patch" on project root. > > Regards, > Rudy > > > Index: test/fakesmsc.c > =================================================================== > --- test/fakesmsc.c (revision 4995) > +++ test/fakesmsc.c (working copy) > @@ -307,6 +307,8 @@ > /* something went off, let's see if it's stdin */ > if (FD_ISSET(fileno(fp), &rset)) { /* stdin is readable */ > cptr = fgets(buffer, IN_BUFSIZE, stdin); > + if (!cptr) > + goto over; > if( strlen( cptr ) < 2 ) > goto rcv; > } else { /* timer kicked in */ > <fakesmsc-gracefully-quits-when-eof.patch>
