git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add test-tr: poor-man tr

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jun 12, 2008, 07:25 UTC
Message-ID
<alpine.DEB.1.00.0806120822140.1783@racer>
In-Reply-To
<556d90580806112332s25f76caajaaafa8e16e895922@mail.gmail.com>
Hi,
On Thu, 12 Jun 2008, Alf Clement wrote:
Show 5 quoted lines
> > +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

Previous: Alf ClementNext: Alex Riesen
Message 13 of 14 in “Add test-tr: poor-man tr”
  1. Add test-tr: poor-man trAlex Riesen, Jun 11, 2008
  2. Use test-tr in the testsAlex Riesen, Jun 11, 2008
  3. Alex RiesenJun 11, 2008
  4. Jeff KingJun 11, 2008
  5. Alex RiesenJun 12, 2008
  6. Jeff KingJun 12, 2008
  7. Jeff KingJun 12, 2008
  8. Alex RiesenJun 12, 2008
  9. Jeff KingJun 13, 2008
  10. Alex RiesenJun 13, 2008
  11. Jeff KingJun 13, 2008
  12. Alf ClementJun 12, 2008
  13. Johannes SchindelinJun 12, 2008
  14. Add test-tr: poor-man trAlex Riesen, Jun 12, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.