<html><head></head><body>Overriding errno on success looks like a bad idea. It wouldn't be the first time that it breaks error handling in nonobvious manner.<br><br>And FWIW, I don't agree with the assessment that bugs in libc syscall wrappers cannot be coded around - especially if you target only one specific ISA.<br><br><div class="gmail_quote">Le 29 mars 2019 15:02:28 GMT+02:00, "Hugo Beauzée-Luyssen" <hugo@beauzee.fr> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On some devices (at least up to Android 6) sendmsg will return its error<br>code on 32bits instead of 64.<br>Most likely some code is storing the ssize_t on a size_t, getting rid of<br>the sign bit and therefore of the sign extension afterward.<br>This causes us to use 0xFFFFFFFF as a very large number of bytes instead<br>of an error.<br>This patch works around the issue and assumes that 0xFFFFFFFF with a non<br>0 errno is an error and forces it to be returned on 64bits.<hr> include/vlc_network.h | 23 +++++++++++++++++++++++<br> 1 file changed, 23 insertions(+)<br><br>diff --git a/include/vlc_network.h b/include/vlc_network.h<br>index 7cc384587a..477d351cc8 100644<br>--- a/include/vlc_network.h<br>+++ b/include/vlc_network.h<br>@@ -280,6 +280,29 @@ static inline int net_GetPeerAddress( int fd, char *address, int *port )<br> <br> VLC_API char *vlc_getProxyUrl(const char *);<br> <br>+#if defined(__ANDROID__) && defined(__aarch64__)<br>+<br>+/**<br>+ * Since we bumped the NDK version from 14 to 18, some devices (at least up to<br>+ * Android 6) are returning errors on 4 bytes, even though ssize_t is actually<br>+ * 8 bytes. This causes `value < 0` checks to yield false, and consider the value<br>+ * as a non error.<br>+ * As the patch lies in either the NDK or the Android kernel, or the device libc<br>+ * we can only work around it. If errno is not 0 & we receive -1, on 32bits or<br>+ * 64bits, we assume an error was returned.<br>+ */<br>+static inline ssize_t vlc_sendmsg(int fd, const struct msghdr *msg, int flags)<br>+{<br>+ errno = 0;<br>+ ssize_t ret = sendmsg(fd, msg, flags);<br>+ if ((ret < 0 || ret == 0xFFFFFFFF) && errno != 0)<br>+ return -1;<br>+ return ret;<br>+}<br>+#define sendmsg(a, b, c) vlc_sendmsg(a,b,c)<br>+<br>+#endif<br>+<br> # ifdef __cplusplus<br> }<br> # endif</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>