Bug 10441 - Backtraces code example lacks error checking
Summary: Backtraces code example lacks error checking
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: manual (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.32
Assignee: Roland McGrath
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-24 13:39 UTC by Christian Convey (work)
Modified: 2020-05-29 13:10 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Convey (work) 2009-07-24 13:39:36 UTC
On this page:  
   http://www.gnu.org/software/libc/manual/html_node/Backtraces.html
there's a code example near the bottom of the page.

That code makes use of the return value from "backtrace_symbols", without 
first checking if the returned pointer is NULL.

You might argue that this code is just to get the general idea across, and is 
rightfully devoid of error checking.  That's obviously an editorial decision.  
What I can say is that, perhaps like many other people, I followed that 
example's structure without giving it much more thought, and in doing so 
unwittingly introducing a bug into my application.  So for that reason you 
might want to add error handling to the example code.
Comment 1 Jonny Grant 2019-03-30 22:42:02 UTC
Hi
I see this is 10 years and not updated...

Can put a bug bounty of $30 on this for a fix.

BTW, also the size_t size; is not correct, it returns int.

and the printf then needs update to %d
Comment 2 Adhemerval Zanella 2020-05-29 13:10:03 UTC
Fixed on 2.32 (5d5b3bd94ceebe13d54a6e0cc9e2a899adbbc56f).