[question] libbb/get_line_from_file.c : bb_get_chunk_from_file function meet the '\0', maybe not break, should continue?

dengke.du at windriver.com dengke.du at windriver.com
Tue Sep 6 07:20:11 UTC 2016


Hi all

In file ./libbb/get_line_from_file.c, function bb_get_chunk_from_file 
contain the following:

         while ((ch = getc(file)) != EOF) {
                 /* grow the line buffer as necessary */
                 if (!(idx & 0xff))
                         linebuf = xrealloc(linebuf, idx + 0x100);
                 linebuf[idx++] = (char) ch;
                 if (ch == '\0')
                         break;
                 if (end && ch == '\n')
                         break;
         }

If we want to get a complete line, when it meets '\0', maybe not break, 
should continue?

Thanks

//dengke


More information about the busybox mailing list