Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000316 [1003.1(2004)/Issue 6] System Interfaces Comment Error 2010-09-17 08:30 2018-09-11 14:20
Reporter ajosey View Status public  
Assigned To ajosey
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Andrew Josey
Organization The Open Group
User Reference XSHbug2.txt Enhancement Request Number 232
Section fprintf
Page Number 0
Line Number 0
Interp Status Approved
Final Accepted Text Note: 0000553
Summary 0000316: fprintf EOVERFLOW
Description  In http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html [^]
 the standard says:

   Upon successful completion, the fprintf() and printf() functions
   shall return the number of bytes transmitted.

   Upon successful completion, the sprintf() function shall return the
   number of bytes written to s, excluding the terminating null byte.

 but with some particular formats, this number of bytes may be larger
 than {INT_MAX} thus not representable in an int (the return type of
 these functions). This problem is solved for the snprintf function.
 Indeed the standard says:

   The snprintf() function shall fail if:

   [EOVERFLOW]
     [XSI] The value of n is greater than {INT_MAX} or the number of
     bytes needed to hold the output excluding the terminating null
     is greater than {INT_MAX}.

 but nothing about this case for the fprintf(), printf() and sprintf()
 functions. The ISO C standard does not handle this case either. As an
 example for platforms with a 32-bit int:

 #ifndef N
 #define N 2147483648
 #endif

 #define STRINGIFY(S) #S
 #define MAKE_STR(S) STRINGIFY(S)

 #define SN MAKE_STR(N)

 #include <stdio.h>

 int main (void)
 {
   int ret;

   ret = printf ("%" SN "d%" SN "d", 1, 1);
   fprintf (stderr, "ret = %d\n", ret);
   return 0;


 }


Desired Action  Replace

   The snprintf() function shall fail if:

   [EOVERFLOW]
     [XSI] The value of n is greater than {INT_MAX} or the number of
     bytes needed to hold the output excluding the terminating null
     is greater than {INT_MAX}.

 by

   The printf(), fprintf(), snprintf() and sprintf() functions shall
   fail if:

   [EOVERFLOW]
     [XSI] The number that should be returned is greater than
     {INT_MAX}.


Tags tc1-2008
Attached Files

- Relationships
related to 0000468Closedajosey 1003.1(2008)/Issue 7 fgets() description misleading in case of immediate EOF 

-  Notes
(0000553)
ajosey (manager)
2010-09-17 08:31

This is published as Austin Group Interpretation reference
1003.1-2001 #214

https://www.opengroup.org/austin/interps/uploads/40/16011/AI-214.txt [^]

Interpretation response
------------------------

The standard states the requirements for the error handling for the
printf family of functions, and conforming implementations must conform
to this. However, concerns have been raised about this which are being
referred to the sponsor.

Rationale:
-------------
None.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
(this is targeted for TC1)

The following changes are based on austin-group-l mail sequence 11282

Add the following [EOVERFLOW] error under the ERRORS section
(in the Rebision) introduced by
"In addition, all forms of fprintf( ) shall fail if:",

   [EOVERFLOW]
     [CX] The value to be returned is greater than {INT_MAX}.

And then change the existing [EOVERFLOW] error for snprintf() to:

   [EOVERFLOW]
     [CX] The value of n is greater than {INT_MAX}.

(Note the use of CX shading in both cases - in the revision the
existing EOVERFLOW has changed from XSI to CX.)


Then in XSH 2.3 Error Numbers add to the end of the existing
paragraph 6 which says
"The ERRORS section on each reference page specifies which error
conditions shall be detected by all implementations (``shall
fail'') and which may be optionally detected by an implementation
(``may fail''). If no error condition is detected, the action
requested shall be successful."

(new text to add):
If an error condition is detected, the action requested may have
been partially performed, unless otherwise stated.

- Issue History
Date Modified Username Field Change
2010-09-17 08:30 ajosey New Issue
2010-09-17 08:30 ajosey Status New => Under Review
2010-09-17 08:30 ajosey Assigned To => ajosey
2010-09-17 08:30 ajosey Name => Andrew Josey
2010-09-17 08:30 ajosey Organization => The Open Group
2010-09-17 08:30 ajosey User Reference => XSHbug2.txt Enhancement Request Number 232
2010-09-17 08:30 ajosey Section => fprintf
2010-09-17 08:30 ajosey Page Number => 0
2010-09-17 08:30 ajosey Line Number => 0
2010-09-17 08:30 ajosey Interp Status => Approved
2010-09-17 08:31 ajosey Note Added: 0000553
2010-09-17 08:31 ajosey Final Accepted Text => Note: 0000553
2010-09-17 08:31 ajosey Status Under Review => Interpretation Required
2010-09-17 08:31 ajosey Resolution Open => Future Enhancement
2010-09-17 08:32 ajosey Tag Attached: issue8
2011-04-28 15:10 nick Tag Detached: issue8
2011-04-28 15:10 nick Tag Attached: tc1-2008
2011-07-01 18:18 eblake Relationship added related to 0000468
2013-04-16 13:06 ajosey Status Interpretation Required => Closed
2018-09-11 14:20 geoffclare Resolution Future Enhancement => Accepted As Marked


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker