> Another small bug in that code is that arguments or even fmt might > actually end with a valid \0 byte that should be appended and counted > (not a c-string terminating byte). > > This check should be done once, with controlled fmt and arguments so > that we can detect problems reliably. You can do that at module > initialization time, for example (./configure might be too early because > libraries might change) and set a static SnprintfCountsTerminator > variable accordingly. > > char buf[16]; > SprintfCountsTerminator = snprintf(buf, sizeof(buf), "%s", "1") == 2;
Clever! Done. -- /kinkie