This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: snprintf allocates memory?!?


On Thu, Apr 10, 2008 at 10:15:10PM +0200, Jim Meyering wrote:
> There is a surprising bug in glibc's snprintf:
> it can _allocate memory_ (and an arbitrarily large amount)
> even for a tiny buffer.  Just filed as BZ 441945.
> Obviously, snprintf should never need to call malloc.

Why?

POSIX says:
Implementations may support additional errors not included in this list, may
generate errors included in this list under circumstances other than those
described here, or may contain extensions or limitations that prevent some
errors from occurring. The ERRORS section on each reference page specifies
whether an error shall be returned, or whether it may be returned.
Implementations shall not generate a different error number from the ones
described here for error conditions described in this volume of IEEE Std
1003.1-2001, but may generate additional errors unless explicitly disallowed
for a particular function.

and I certainly don't see anything explicitly disallowing ENOMEM for
snprintf.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]