Skip to content
Snippets Groups Projects
Commit e86f2a05 authored by Tom Lane's avatar Tom Lane
Browse files

Ensure _dosmaperr() actually sets errno correctly.

If logging is enabled, either ereport() or fprintf() might stomp on errno
internally, causing this function to return the wrong result.  That might
only end in a misleading error report, but in any code that's examining
errno to decide what to do next, the consequences could be far graver.

This has been broken since the very first version of this file in 2006
... it's a bit astonishing that we didn't identify this long ago.

Reported by Amit Kapila, though this isn't his proposed fix.
parent 654e006b
No related branches found
No related tags found
No related merge requests found
......@@ -179,14 +179,16 @@ _dosmaperr(unsigned long e)
{
if (doserrors[i].winerr == e)
{
errno = doserrors[i].doserr;
int doserr = doserrors[i].doserr;
#ifndef FRONTEND
ereport(DEBUG5,
(errmsg_internal("mapped win32 error code %lu to %d",
e, errno)));
e, doserr)));
#elif FRONTEND_DEBUG
fprintf(stderr, _("mapped win32 error code %lu to %d"), e, errno);
fprintf(stderr, _("mapped win32 error code %lu to %d"), e, doserr);
#endif
errno = doserr;
return;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment