mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-18 14:20:09 +01:00
Fix crash if non-GNU strerror_r is used.
The strerror_r call exists in POSIX and GNU variant, if POSIX variant is used (like in musl libc replacement) we cannot rely on char* pointer. Fixes issue#237.
This commit is contained in:
@@ -62,6 +62,7 @@ AC_TYPE_OFF_T
|
|||||||
AC_SYS_LARGEFILE
|
AC_SYS_LARGEFILE
|
||||||
AC_FUNC_FSEEKO
|
AC_FUNC_FSEEKO
|
||||||
AC_PROG_GCC_TRADITIONAL
|
AC_PROG_GCC_TRADITIONAL
|
||||||
|
AC_FUNC_STRERROR_R
|
||||||
|
|
||||||
dnl ==========================================================================
|
dnl ==========================================================================
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ int yesDialog(const char *msg, void *usrptr __attribute__((unused)))
|
|||||||
|
|
||||||
void show_status(int errcode)
|
void show_status(int errcode)
|
||||||
{
|
{
|
||||||
char error[256], *error_;
|
char error[256];
|
||||||
|
|
||||||
if(!opt_verbose)
|
if(!opt_verbose)
|
||||||
return;
|
return;
|
||||||
@@ -175,12 +175,16 @@ void show_status(int errcode)
|
|||||||
|
|
||||||
crypt_get_error(error, sizeof(error));
|
crypt_get_error(error, sizeof(error));
|
||||||
|
|
||||||
if (!error[0]) {
|
if (*error) {
|
||||||
error_ = strerror_r(-errcode, error, sizeof(error));
|
#ifdef STRERROR_R_CHAR_P /* GNU-specific strerror_r */
|
||||||
if (error_ != error) {
|
char *error_ = strerror_r(-errcode, error, sizeof(error));
|
||||||
|
if (error_ != error)
|
||||||
strncpy(error, error_, sizeof(error));
|
strncpy(error, error_, sizeof(error));
|
||||||
error[sizeof(error) - 1] = '\0';
|
#else /* POSIX strerror_r variant */
|
||||||
}
|
if (strerror_r(-errcode, error, sizeof(error)))
|
||||||
|
*error = '\0';
|
||||||
|
#endif
|
||||||
|
error[sizeof(error) - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
log_err(_("Command failed with code %i"), -errcode);
|
log_err(_("Command failed with code %i"), -errcode);
|
||||||
|
|||||||
Reference in New Issue
Block a user