home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / utils / bug / 2071 < prev    next >
Encoding:
Text File  |  1992-11-17  |  1.2 KB  |  33 lines

  1. Newsgroups: gnu.utils.bug
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tera.com!rrh
  3. From: rrh@tera.com (Robert R. Henry)
  4. Subject: glibc1.05 buglet in sprintf/fwrite when typeof(size_t)==int
  5. Message-ID: <9211171704.AA04319@tera.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Tue, 17 Nov 1992 17:04:07 GMT
  10. Approved: bug-gnu-utils@prep.ai.mit.edu
  11. Lines: 20
  12.  
  13. I built a version of glibc using gcc2.2.2 in a cross
  14. development environment, target=sun3 host=sun4,
  15. intended to run a standalone 68020 based platform.
  16.  
  17. it seems with this configuration of gcc2.2.2 that size_t is an int,
  18. to be consistent (urgh) with sun-lossage; clearly, it should be
  19. an unsigned.  This is a tremendous rathole, I realize.
  20.  
  21. in vsprintf is the line
  22.   f.__bufsize = (size_t) (f.__put_limit - f.__bufp);
  23. in which __put_limit is initialized to 0xffffffff;
  24. this ends up giving f.__bufsize a large negative number (since size_t
  25. is an int), which then causes these lines in fwrite
  26.     if (n > buffer_space)
  27.       n = buffer_space;
  28. to be executed (n is now < 0), which is later used as an argument to
  29.         memcpy ((PTR) stream->__bufp, (PTR) p, n);
  30. and since n < 0 memcpy fortunately copies nothing.
  31.  
  32.  
  33.