NNTPC: printf with long strings (nntpcache-1.0)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Julian Assange writes:
  
  Ick. I presume you are refering to the heavy usage of the "%.128s" etc
  construct. This notice that the field width is *after* the full-stop.
  This limits the number of characters sprinted, but doesn't pad.
  
  Can you perhaps try a test program under sunos-4.1.x to see what the
  result is?
  
I'm not sure I've created the proper test.  I tried


----------[ptest.c]----------
#include <stdio.h>

main()
{
  char *longstring = "This is a very long string to see what happens to printf under Suns-4.1.3";
  char *path = "news.connix.com/comp/infosystems/www/servers/unix/12345";
  char buf[BUFSIZ];
  int len;

  len = strlen(longstring);

  sprintf (buf, "%d    %.255s\n%.348s", len, longstring, path);
  puts(buf);
}
-----------[eof]-----------

which produces correct results

----------[ptest output]----------
73    This is a very long string to see what happens to printf under Suns-4.1.3
news.connix.com/comp/infosystems/www/servers/unix/12345
-----------[eof]-----------

Yet the entries for long pathnames in cache.history here are
truncated (the first is correct; the last two are lopped off):

-----------[cache.history]-----------
71   55v2iu$j87@lyra.csx.cam.ac.uk
news.connix.com/comp/text/tex/46852
82   55umc0$6uu@gold.interlog.com
news.connix.com/comp/infosystems/www/servers/un
83   55ts53$ni@gazette.bcm.tmc.edu
news.connix.com/soc/history/war/world-war-ii/21
-----------[eof]-----------

If you want to suggest a test that will more exactly duplicate the
code in nntpcache-1.0/history.c, I'll be glad to try it.

-- 

   Ronald Florence		Maple Lawn Farm, Stonington, CT
   ron@mlfarm.com		http://www.connix.com/~mlfarm


[Index of Archives]     [Yosemite]     [Yosemite Campsites]     [Bugtraq]     [Linux]     [Trn]

Powered by Linux