Skip to content

-Werror=int-conversion warning in ssh_strerror when using strerror_r with musl

Hello, I updated to 0.10.0 for on alpine build (which uses musl libc) and got this warning and error because of -Werror:

/libssh-mirror-libssh-0.10.0/src/misc.c: In function 'ssh_strerror':
/libssh-mirror-libssh-0.10.0/src/misc.c:1961:12: error: returning 'int' from a function with return type 'char *' makes pointer from integer without a cast [-Werror=int-conversion]
1961 |     return strerror_r(err_num, buf, buflen);
     |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When I looked up the documentation for strerror_r it seems to behave a bit differently depending on environment and for musl it has the "XSI-compliant" behaviour if i understand it correctly. That means it returns an int that is zero on success or an errno on errors. GNU version returns a pointer to a string.

Strangely it seems like the libssh package on alpine built successfully with 0.10.0 https://git.alpinelinux.org/aports/tree/community/libssh/APKBUILD but maybe it builds with different warnings so it did not fail? looking at how ssh_strerror is used it seems like this would probably cause a crash?

Possible related commit 51c940ad

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information