In message <mailman.2184.1277626565.32709.python-l...@python.org>, Kushal Kumaran wrote:
> On Sun, Jun 27, 2010 at 9:47 AM, Lawrence D'Oliveiro > <l...@geek-central.gen.new_zealand> wrote: > >> In message <roy-854954.20435125062...@news.panix.com>, Roy Smith wrote: >> >>> I recently fixed a bug in some production code. The programmer was >>> careful to use snprintf() to avoid buffer overflows. The only problem >>> is, he wrote something along the lines of: >>> >>> snprintf(buf, strlen(foo), foo); >> >> A long while ago I came up with this macro: >> >> #define Descr(v) &v, sizeof v >> >> making the correct version of the above become >> >> snprintf(Descr(buf), foo); > > Not quite right. If buf is a char array, as suggested by the use of > sizeof, then you're not passing a char* to snprintf. What am I passing, then? -- http://mail.python.org/mailman/listinfo/python-list