[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Confusing "Success" error message
From: |
Andries E. Brouwer |
Subject: |
Re: Confusing "Success" error message |
Date: |
Wed, 5 May 2021 14:38:05 +0200 |
On Fri, Nov 08, 2019 at 07:06:15PM +0200, Eli Zaretskii wrote:
>> Did you read the line "a function that succeeds is allowed
>> to change errno"?
>
> Yes, but that's against every library whose sources I've ever read.
Today I got the error message
Cannot write to ‘<dir>’ (Success).
from wget-1.21 compiled with openssl.
strace shows that openat returns EISDIR
where was this value lost?
The error message "Cannot write to ..." was printed in http.c
by the code
case FWRITEERR: case FOPENERR:
logputs (LOG_VERBOSE, "\n");
logprintf (LOG_NOTQUIET, _("Cannot write to %s (%s).\n"),
quote (hstat.local_file), strerror (errno));
The errno value EISDIR is set by
err = open_output_stream (hs, count, &fp);
in that same file. The following lines are
if (err != RETROK)
{
CLOSE_INVALIDATE (sock);
retval = err;
goto cleanup;
}
and before the CLOSE_INVALIDATE errno has the value EISDIR,
after it errno has the value 0.
Where does this value change? CLOSE_INVALIDATE calls fd_close (fd);
and before that call errno has the value EISDIR, afterwards it is 0.
Where does fd_close change errno? The code is
if (info && info->imp->closer) {
info->imp->closer (fd, info->ctx);
} else {
sock_close (fd);
}
and the call info->imp->closer() changed errno.
What was this closer here? It was openssl_close().
It calls
SSL_shutdown (conn);
and before that call errno is EISDIR, after it errno is 0.
So, maybe we can conclude that Eli Zaretskii has not read
the openssl source. Anyway, the standard says that any
succesful library call is allowed to change errno,
and good programming practice would save errno if it
was needed later.
Andries
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Confusing "Success" error message,
Andries E. Brouwer <=