From: Johannes Schindelin Date: Thu, 12 Jun 2008 07:25:09 GMT Subject: Re: [PATCH] Add test-tr: poor-man tr Message-ID: In-Reply-To: <556d90580806112332s25f76caajaaafa8e16e895922@mail.gmail.com> Hi, On Thu, 12 Jun 2008, Alf Clement wrote: > > +static unsigned char *unquote(const char *s, unsigned *len) +{ > > + unsigned char *result = malloc(strlen(s)), *r = result; > > are you sure that the buffer is big enough?? Nomally you do a > malloc(strlen(s)+1). AFAIU a "tr" really only ever replaces single characters by single characters. So, not even looking at the code -- just like you -- I would expect it to get the exact number of bytes read, and to write the same number of bytes. I certainly would not expect it to do something string based, introducing a silly expectation of NUL-terminations (which tr(1) does not expect either). Ciao, Dscho