Bug 229720 - src/lib/libugidfw/ugidfw.c:105: poor error checking ?
Summary: src/lib/libugidfw/ugidfw.c:105: poor error checking ?
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-12 10:48 UTC by David Binderman
Modified: 2018-07-12 10:48 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2018-07-12 10:48:21 UTC
src/lib/libugidfw/ugidfw.c:105]: (style) Checking if unsigned variable 'len' is less than zero.

Source code is

           len = snprintf(cur, left, "uid %s",
                                    pwd->pw_name);
           if (len < 0 || len > left)

but len is unsigned and the return value from snprintf is int. 

Suggest sanity check return value before assignment into unsigned variable.

Multiple duplicates:

src/lib/libugidfw/ugidfw.c:112]: (style) Checking if unsigned variable 'len' is less than zero.
[src/lib/libugidfw/ugidfw.c:123]: (style) Checking if unsigned variable 'len' is less than zero.
[src/lib/libugidfw/ugidfw.c:130]: (style) Checking if unsigned variable 'len' is less than zero.
[src/lib/libugidfw/ugidfw.c:137]: (style) Checking if unsigned variable 'len' is less than zero.
[src/lib/libugidfw/ugidfw.c:145]: (style) Checking if unsigned variable 'len' is less than zero.
[src/lib/libugidfw/ugidfw.c:155]: (style) Checking if unsigned variable 'len' is less than zero.
[src/lib/libugidfw/ugidfw.c:162]: (style) Checking if unsigned variable 'len' is less than zero.
[src/lib/libugidfw/ugidfw.c:173]: (style) Checking if unsigned variable 'len' is less than zero.
[src/lib/libugidfw/ugidfw.c:180]: (style) Checking if unsigned variable 'len' is less than zero.
...