The squid_kerb_auth unterminated string change

From: Henrik Nordstrom <henrik_at_henriknordstrom.net>
Date: Mon, 13 Jul 2009 12:43:24 +0200

Hi Markus

i just saw this change which copies the user string a temporary buffer
only to \0 terminate it before printf

  http://www.squid-cache.org/Versions/v3/3.0/changesets/b9061.patch

While entirely fine it's a little more complex than it need to be.

Instead of copying the unterminated string you can apply a size limit to
the output. Size limit for %s is in the precision field and causes at
most that many characters to be copied to the output. When combined with
the * size specifier one can easily print sized strings without the need
for \0 termination.

   printf("%.*s\n", token.length, token.data);

Regards
Henrik
Received on Mon Jul 13 2009 - 10:43:30 MDT

This archive was generated by hypermail 2.2.0 : Tue Jul 14 2009 - 12:00:05 MDT