Re: [PATCH 3/6] refactored output function
Dave Jones <[email protected]>
| Newsgroups | org.kernel.vger.trinity |
|---|---|
| Message-ID | <[email protected]> |
Since applying this patch, coverity is picking up an out of bounds write.
It looks like it can't happen, but I'm wondering why this code was
done this way..
hand-editted diff for clarity:
> /* copy buffer, sans ANSI codes */
> len = strlen(outputbuf);
> - for (i = 0, j = 0; i < len; i++) {
> + for (i = 0, j = 0; (i < len) && (i + 2 < BUFSIZE) && (j < BUFSIZE); i++) {
> if (outputbuf[i] == '') {
> if (outputbuf[i + 2] == '1')
> i += 6; // ANSI_COLOUR
> else
> i += 3; // ANSI_RESET
> } else {
> monobuf[j] = outputbuf[i];
> j++;
> }
> }
> monobuf[j] = '\0';
What's the intent behind this ?
It seems redundant, as everything seems to work fine without this change.
Dave