On 2010-06-15 00:08, Max Laier wrote: > I'm not sure about the intention behind the len assignements in libugidfw - > might be just a leftover - but if the idea is to teach a model that "we > generally care about the return value of snprintf()", a void cast might be the > more protable solution. These specific snprintf() calls all occur just before returning an error, so checking the return value is quite useless (unless one wanted to output some sort of overflow warning right there). Moreover, all calls to snprintf() in lib/libugidfw/ugidfw.c that do check the return value are incorrect in two ways: - The return value is stored in a size_t, while snprintf() returns an int. Thus all the checks "ret < 0" become bogus. - The idiom used everywhere is: len = snprintf(cur, left, ...); if (len < 0 || len > left) goto truncated; which is wrong; the second check should be "len >= left" instead. Please review the attached patch which fixes those problems too.
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:04 UTC