NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/45672: usr.sbin/user generates incorrect error messages



>Number:         45672
>Category:       bin
>Synopsis:       usr.sbin/user generates incorrect error messages
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 30 16:25:00 +0000 2011
>Originator:     River Tarnell
>Release:        NetBSD 5.1.0_PATCH
>Organization:
RT.UK.EU.ORG
>Environment:
System: NetBSD tamara.rt.uk.eu.org 5.1.0_PATCH NetBSD 5.1.0_PATCH (TAMARA) #2: 
Thu Aug 4 18:30:08 UTC 2011 
root%tamara.tcx.org.uk@localhost:/usr/src/sys/arch/amd64/compile/TAMARA amd64
Architecture: x86_64
Machine: amd64
>Description:
usr.sbin/user/user.c contains this error handling code in asystem():

        if ((ret = system(buf)) != 0) {
                warn("Error running `%s'", buf);
        }

This will print the errno value if system() returns >0, which is wrong, because 
errno is not set in this case, so a junk error message will be output.
>How-To-Repeat:
Code inspection.
>Fix:
        switch (ret = system(buf)) {
        case 0:         break;
        case -1:        warn("Error running `%s'", buf); break;
        default:        warnx("Error running `%s'", buf); break;
        }



Home | Main Index | Thread Index | Old Index