In message <[email protected]>, mdf@
FreeBSD.org writes:

>It seems like a large project, but OTOH sprintf(9) is mighty unsafe in
>the kernel.

Well, it is only unsafe if people used it without knowing what they
are doing, so I think a wholesale automated replacement is both
unwarranted and inadvisable.

I can recommend the following macro for the static buffer cases, it
checks if people know what they are doing with an assert.

#define bprintf(buf, fmt, ...)                                          \
        do {                                                            \
                assert(snprintf(buf, sizeof buf, fmt, __VA_ARGS__)      \
                    < sizeof buf);                                      \
        } while (0)

Poul-Henning

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
[email protected]         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[email protected]"

Reply via email to