Project

General

Profile

Bug #9522

mksh misreports errno

Added by Dan McDonald over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
tools - gate/build tools
Start date:
2018-05-07
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage

Description

mksh has many instances of this anti-pattern:

if (syscall() == -1)
    exit_fatal(getmsg("oh no, syscall has error %s\n"), strerror(errno));

getmsg() may evaluate first, clobbering errno before strerror() gets called. A fix would resemble:

if (syscall() == -1) {
    int save_errno = errno; /* getmsg() clobbers errno */
    exit_fatal(getmsg("oh no, syscall has error %s\n"), strerror(save_errno));
}

NOTE: Other parts of dmake, or for that matter the rest of the system, may have a similar anti-pattern.

History

#1

Updated by Dan McDonald over 1 year ago

  • Status changed from New to Closed

Not a bug in gate - gettext() preserves errno. I mistakenly thought SmartOS used -gate's dmake, it does not, see: https://smartos.org/bugview/OS-4960

Also available in: Atom PDF