On 10/31/07, Sander van Dijk <[EMAIL PROTECTED]> wrote: > > On Oct 31, 2007 7:01 AM, Vasil Dimov <[EMAIL PROTECTED]> wrote: > > On Tue, Oct 30, 2007 at 23:04:33 -0400, Ritesh Kumar wrote: > > [...] > > > I went through the source code and fixed the status input handling > code to > > > make sure it flushes the input status text only if in encounters a > '\n'. > > [...] > > > if(FD_ISSET(STDIN_FILENO, &rd)) { > > > - switch(r = read(STDIN_FILENO, inputtext, > sizeof inputtext - 1)) { > > > + pos = inputtext[strlen(inputtext)-1] != '\n' ? > strlen(inputtext) : 0; > > > + switch(r = read(STDIN_FILENO, > &(inputtext[pos]), sizeof inputtext - 1 - pos)) { > > [...] > > > > Hmmz, aren't you trying to calculate strlen() of something undefined > > here? > > And also, when inputtext[0] = '\0', where does > inputtext[strlen(inputtext)-1] point to?
Nice catch! Actually, I didn't think of this when I first developed the patch. However, the read() call always returns atleast one char in inputtext for the default switch case. So, we are always bound to have strlen(inputtext) > 1 for all cases. But I guess its better to be safe and put a check in for strlen(inputtext) while calculating pos. _r