Bug 1202104 - Incorrect use of strtol in logger.c
Summary: Incorrect use of strtol in logger.c
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: 21
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-15 13:05 UTC by Stef Walter
Modified: 2015-06-03 09:19 UTC (History)
2 users (show)

Fixed In Version: util-linux-2.26.2-1.fc22
Clone Of:
Environment:
Last Closed: 2015-06-03 09:19:12 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
logger: Fix use of uninitialized errno (1.35 KB, patch)
2015-03-15 13:20 UTC, Stef Walter
no flags Details | Diff

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.


Note You need to log in before you can comment on or make changes to this bug.