This is the mail archive of the
mailing list for the eCos project.
Re: Should we add compiler warnings to diag_sprintf & diag_vsprintf ?
- From: Rutger Hofman <rutger at cs dot vu dot nl>
- To: Chris Holgate <chris at zynaptic dot com>
- Cc: ecos-devel at ecos dot sourceware dot org
- Date: Fri, 26 Jun 2009 14:24:43 +0200
- Subject: Re: Should we add compiler warnings to diag_sprintf & diag_vsprintf ?
- References: <4A44B683.firstname.lastname@example.org> <4A44BC4E.email@example.com>
Rutger Hofman wrote:
Chris Holgate wrote:
I've just had to add support for diag_vsnprintf to diag.h as part of
writing some logging code. We all know that sprintf, vsprintf and their
evil unchecked spawn are the source of lots of buffer overflow bugs -
so while I'm prepping a patch for this change is it worth adding
compiler warning attributes to diag_sprintf and diag_vsprintf to help
'discourage' their use?
That would collide with -Werror -- an option I happen to like a lot.
Besides, my guess is that the vsnprintf functions will be called through
some printf-style variadic function, and the compiler can verify
Ach, I misunderstood. You want to discourage diag_sprintf and
diag_vsprintf in favour of diag_vsnprintf. I fully agree here.