Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Date: Fri, 04 Mar 2022 11:39:22 +0100
From: Florian Weimer <fweimer@...hat.com>
To: libc-coord@...ts.openwall.com
Subject: Checking for insufficient buffer space in swprintf

How is a programmer expected to check for insufficient buffer space in
swprintf?

Unlike snprintf, POSIX requires an error (negative return value) for
insufficient buffer space.  But POSIX does not specify the error code.
Assuming that the last byte in the buffer is overwritten with NUL (the
fgets check) is not portable; the glibc implementation does not do that.
Checking for errno not being written after a negative routine does not
seem to be portable, either, and the current behavior in some
implementations of not setting errno is against POSIX (which requires
errno to be set).

strfmon specifies the E2BIG error code for the situation.  Should we use
the same error code for swprintf?

(This is separate from the INT_MAX issue for the return value, that
error case has settled on EOVERFLOW.)

Thanks,
Florian

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.