1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-15 23:35:34 +00:00

Work around fsp_open_session() not setting errno.

fsp_open_session() has a bug where it does not set errno if getaddrinfo fails.
Before the bug 1013 fix, this caused an assertion failure.
After the bug 1013 fix, this caused a "Success" error message.
Now it instead causes "FSP server not found".
This commit is contained in:
Kalle Olavi Niemitalo 2008-08-03 17:48:11 +03:00 committed by Kalle Olavi Niemitalo
parent 6c2e8cd7b2
commit c1ffba2f95
4 changed files with 21 additions and 2 deletions

2
NEWS
View File

@ -21,7 +21,7 @@ includes the changes listed under "ELinks 0.11.4.GIT now" below.
JS_CallFunction, which can crash if given a closure.
* critical bug 1031: Use the same JSRuntime for both user SMJS and
scripts on web pages, to work around SpiderMonkey bug 378918.
* bug 1013: Don't assume errno values are between 0 and 100000
* bug 1013: Don't assume errno values are between 0 and 100000.
* bug 1022: Add connection.ssl.trusted_ca_file setting for GnuTLS.
Before this, ELinks did not trust any certificate authorities when
it used GnuTLS, so certificate verification always failed if you

View File

@ -126,6 +126,13 @@ static const struct s_msg_dsc msg_dsc[] = {
{S_BITTORRENT_BAD_URL, N_("The BitTorrent URL does not point to a valid URL")},
#endif
/* fsp_open_session() failed but did not set errno.
* fsp_open_session() never sends anything to the FSP server,
* so this error does not mean the server itself does not work.
* More likely, there was some problem in asking a DNS server
* about the address of the FSP server. */
{S_FSP_OPEN_SESSION_UNKN, N_("FSP server not found")},
{0, NULL}
};

View File

@ -103,6 +103,8 @@ enum connection_basic_state {
S_BITTORRENT_METAINFO = -100801,
S_BITTORRENT_TRACKER = -100802,
S_BITTORRENT_BAD_URL = -100803,
S_FSP_OPEN_SESSION_UNKN = -100900,
};
/** Either an ELinks internal status code or an error code from the

View File

@ -277,8 +277,18 @@ do_fsp(struct connection *conn)
if (auth) password = auth->password;
}
/* fsp_open_session may not set errno if getaddrinfo fails
* https://sourceforge.net/tracker/index.php?func=detail&aid=2036798&group_id=93841&atid=605738
* Try to detect this bug and use an ELinks-specific error
* code instead, so that we can display a message anyway. */
errno = 0;
ses = fsp_open_session(host, port, password);
if (!ses) fsp_error(connection_state_for_errno(errno));
if (!ses) {
if (errno)
fsp_error(connection_state_for_errno(errno));
else
fsp_error(connection_state(S_FSP_OPEN_SESSION_UNKN));
}
/* fsplib 0.8 ABI depends on _FILE_OFFSET_BITS
* https://sourceforge.net/tracker/index.php?func=detail&aid=1674729&group_id=93841&atid=605738