Bug 1202104

Summary: Incorrect use of strtol in logger.c
Product: [Fedora] Fedora Reporter: Stef Walter <stefw>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 21CC: jonathan, kzak
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: util-linux-2.26.2-1.fc22 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-03 09:19:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
logger: Fix use of uninitialized errno none

Description Stef Walter 2015-03-15 13:05:14 UTC
Description of problem:

logger.c incorrectly checks errno after strtol without clearing it first. This leads to the following regression in Fedora 21:

[root@localhost yum.repos.d]# logger -p3 test
logger: unknown priority name: 3

The strtol() manual page specifically states:

NOTES
       Since  strtol()  can  legitimately  return  0,  LONG_MAX,  or  LONG_MIN
       (LLONG_MAX or LLONG_MIN for strtoll()) on both success and failure, the
       calling program should set errno to 0 before the call, and then  deter‐
       mine if an error occurred by checking whether errno has a nonzero value
       after the call.


Version-Release number of selected component (if applicable):

util-linux-2.25.2-2.fc21.x86_64

How reproducible:

On our Cockpit integration test images this happens every time.

Steps to Reproduce:
1. logger -p3 test

Actual results:

logger: unknown priority name: 3

Expected results:

Logged message

Additional info:

Since this uses an uninitialized value in errno, from a previous failure, it's possible that it cannot be reliably reproduced on every system. However it's very clear from reading the code where the problem is.

Comment 1 Stef Walter 2015-03-15 13:19:21 UTC
Scratch build with fix.

Comment 2 Stef Walter 2015-03-15 13:20:46 UTC
Created attachment 1001946 [details]
logger: Fix use of uninitialized errno

Adds patch and updates spec file to fix the issue.

Comment 3 Stef Walter 2015-03-15 13:25:07 UTC
Patch posted to upstream mailing list. http://vger.kernel.org/vger-lists.html#util-linux

Comment 4 Karel Zak 2015-03-16 10:27:31 UTC
Fixed by upstream commit 8d341322dbf4ef80dea7821c858292c7ba5e0b25. Thanks! 

Fedora package will be updated ASAP.