Bug 229713 - src/crypto/heimdal/appl/push/push.c:270: poor error handling ?
Summary: src/crypto/heimdal/appl/push/push.c:270: poor error handling ?
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 (Nobody)
Depends on:
Reported: 2018-07-12 09:30 UTC by David Binderman
Modified: 2018-07-12 09:30 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2018-07-12 09:30:01 UTC
src/crypto/heimdal/appl/push/push.c:270]: (style) Checking if unsigned variable 'from_line_length' is less than zero.

Source code is

    from_line_length = snprintf (from_line, sizeof(from_line),
                                 "From %s %s", "push", ctime(&now));
    if (from_line_length < 0 || from_line_length > sizeof(from_line))
        errx (1, "snprintf failed");

but variable from_line_length is unsigned and the return value
from snprintf is int. 

Suggest sanity check return value from snprintf *before* storing in an unsigned variable.