Opened 10 years ago

Closed 10 years ago

#7159 closed defect (fixed)

Giving strerror a negative value is usually a bad idea

Reported by: Erik Hovland <erik@…> Owned by: Janne Grunau
Priority: trivial Milestone: 0.22
Component: MythTV - General Version: head
Severity: low Keywords:
Cc: Ticket locked: no

Description

strerror() has undefined behavior when given a value that is negative. In the sound code there is an idiom where the error message uses strerror() w/ the return value of the ioctl(). I understand that the ioctl() in this case might return the error. But since that error also has to be negative according to the check of the value, this might cause problems (like segfaults). If this is actually what the author wants, they should flip the sign of the return value before giving it to strerror().

Attachments (1)

libs_libmythtv-negative-returns (3.6 KB) - added by Erik Hovland <erik@…> 10 years ago.
Use errno instead of negative return value when using strerror()

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by Erik Hovland <erik@…>

Use errno instead of negative return value when using strerror()

comment:1 Changed 10 years ago by Janne Grunau

Milestone: unknown0.22
Owner: changed from Isaac Richards to Janne Grunau
Status: newaccepted

comment:2 Changed 10 years ago by Janne Grunau

Resolution: fixed
Status: acceptedclosed

fixed by [22051]

Note: See TracTickets for help on using tickets.