On Wed, 17 Apr 2002, Roman Hunt wrote:

> On Wed, 17 Apr 2002, Simon Glover wrote:
>
> # >+    cstring[s->buflen + 1] = 0;
> good grief
>
> # >
> #
> #  This is a buffer overflow; I'm not quite sure what you're trying to do,
> #  but this certainly doesn't do it.
>
> shouldnt cstring[s->bufused +1] = \0
> to keep us from clobbering the last char? or will string_grow update
> bufused even though we havent 'used' it just yet?
>

 Don't forget that cstring starts at index 0, so cstring[s->bufused] is
 actually one char past the end of the used portion of the buffer. The
 call to string_grow is to ensure that if s->bufused == s->buflen
 initially, we grow the string by enough to be able to stick a null
 char at the end.

 Re. transcoding: I plead complete ignorance - hopefully somebody else
 will be able to tell you if this is the right thing to do.

 Simon




Reply via email to