Sorry, just noticed this one. I added it just for robustness in future, as the buffered output was also working till the point when it got overflown. This way buffer won't be overflown. -Ildar On Thu, Oct 10, 2013 at 11:20 AM, Dave Jones <davej@xxxxxxxxxx> wrote: > 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 > -- To unsubscribe from this list: send the line "unsubscribe trinity" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html