Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Fri, 25 Apr 2014 10:50:36 -0400
From: Rich Felker <>
Subject: Re: looking at fmtmsg-is dprintf oom-safe?

On Thu, Apr 24, 2014 at 09:57:44AM -0700, Isaac Dunham wrote:
> Hello,
> I've been poking at fmtmsg(), since if I added that and used sdbm for
> dbm.h, I'd have XSI coverage.
> Due to the use case for fmtmsg (reporting errors, including terminal
> errors), I expect it needs to work even when malloc() fails.
> My understanding is that this would exclude using fopen().
> I could use several calls to write() (I currently have a preliminary
> version that does this), but dprintf() would be more optimal.
> As far as I can tell, dprintf() should still work when malloc() fails,
> but I'd like to confirm this.

Yes, dprintf runs in O(1) memory (stack) and is async-signal-safe. The
stack usage is tiny unless you're printing floating point, and in the
fp case, something like 512 bytes to 8k depending on arch the size of
long double.


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.