Re: [dev] [st] Reporting a Segmentation fault

From: Martti Kühne <mysatyre_AT_gmail.com>
Date: Sat, 21 Nov 2015 11:08:08 +0100

On Fri, Nov 20, 2015 at 9:00 PM, Greg Reagle <greg.reagle_AT_umbc.edu> wrote:
> That's right--buf is accessed without bounds checked. The problem is in
> ttyread() in the while loop, buf gets overflowed, i.e. ptr - buf exceeds
> BUFSIZ (8192). Haven't figured out how to remedy the problem (yet).
>
>


What makes you think this is an overflow? The leading one-bits in clen
to me clearly hint that this happens through forming a negative
buflen, hence my use of the word underflow.
Apart from that, I still get segfaults with even this overly
pessimistic check in the code:

while ((charsize = utf8decode(ptr, &unicodep, buflen)) &&
  buflen - charsize > 0 && ptr - buf + charsize < BUFSIZ - 4) {
    tputc(unicodep);
    ptr += charsize;
    buflen -= charsize;
}

The underflow on my gdb test being in the minus hundred thousands even
makes it look as if it was something else like the read() call that
overflowed. Eww.

cheers!
mar77i
Received on Sat Nov 21 2015 - 11:08:08 CET

This archive was generated by hypermail 2.3.0 : Sat Nov 21 2015 - 11:12:10 CET