*BSD News Article 9672


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA6269 ; Thu, 07 Jan 93 15:07:38 EST
Path: sserve!manuel.anu.edu.au!munnari.oz.au!bruce.cs.monash.edu.au!monu6!adagio.panasonic.com!sgiblab!darwin.sura.net!haven.umd.edu!uunet!ccut!news.u-tokyo.ac.jp!yayoi!tansei1!mhiroshi
From: mhiroshi@tansei.cc.u-tokyo.ac.jp (H. Murakami)
Newsgroups: comp.unix.bsd,fj.os.386bsd
Subject: A potential danger bug with vfprintf in 386bsd.
Message-ID: <3860@tansei1.tansei.cc.u-tokyo.ac.jp>
Date: 10 Jan 93 01:28:28 GMT
Sender: news@tansei.cc.u-tokyo.ac.jp
Followup-To: comp.unix.bsd
Organization: Hokkaido Univ. However I am subject to tansei for JUNET.
Lines: 44

To: comp.unix.bsd
Subject: A potential danger bug with vfprintf in 386bsd.


% cat a.c
/*
 *  There is potential danger of vfprintf rountine
 *  used in 386bsd.
 *
 *  This is somewhat extraordinal code, since
 *  the format  %50.40le  or like are rather cray 
 *  man's request. However the system  shouldn't 
 *  put the wrong result without error, 
 *  since most computation is carried out 
 *  in the black box manner.
 *  PS. How this could be fixed gracefully?
 */

main()
{
	double x = 1e10;

	printf("%50.37le\n", x);
	printf("%50.38le\n", x);
	printf("%50.39le\n", x);
	printf("%50.40le\n", x);
	printf("%50.41le\n", x);
	printf("%50.42le\n", x);
	printf("%50.43le\n", x);

}


% gcc a.c
% a.out
       1.0000000000000000000000000000000000000e+10
      1.00000000000000000000000000000000000000e+10
     1.000000000000000000000000000000000000000e+10
    1.000000000000000000000000000000000000000e+100   <<< LOOK  !
   1.000000000000000000000000000000000000000e+1000   <<< LOOK  !
  1.000000000000000000000000000000000000000e+10000   <<< LOOK  !
 1.000000000000000000000000000000000000000e+100000   <<< LOOK  !
%
%