Bug 229713

Summary: src/crypto/heimdal/appl/push/push.c:270: poor error handling ?
Product: Base System Reporter: David Binderman <dcb314>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me    
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

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.