[coreboot] need help with #define macro

ron minnich rminnich at gmail.com
Mon Dec 22 18:13:48 CET 2008


On Mon, Dec 22, 2008 at 8:54 AM, Peter Stuge <peter at stuge.se> wrote:
> ron minnich wrote:
>> char *partport = "parport0";
>> static char parportname[MAXPATHLEN];
>>
>> sprintf(parportname, "/proc/sys/dev/parport/%s/base-addr", parport );
>
> Please make sure to always use
>
> snprintf(parportname, sizeof(parportname), "/proc/...", parport);
>
> to avoid buffer overflows, and check the return value. Not that I
> always do, but I should.
>

arg! good point. I have gotten out of the habit of using any of these,
as Plan 9 has this:
smprint(format, ...)

smprint mallocs the buffer as needed.

snprintf now feels SOOO 20th-century, as my daughter might say :-)

ron




More information about the coreboot mailing list