summaryrefslogtreecommitdiffstats
path: root/main/cryptsetup/strerror_r.patch
blob: 6dde3d514aa84e3aedbdbe6719b0e6fc796d36ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
diff --git a/src/utils_tools.c b/src/utils_tools.c
index 4e8b0b4..1b4f3e5 100644
--- a/src/utils_tools.c
+++ b/src/utils_tools.c
@@ -176,11 +176,18 @@ void show_status(int errcode)
 	crypt_get_error(error, sizeof(error));
 
 	if (!error[0]) {
+#if defined(__GLIBC__)
+		/* GNU libc strerror_r is non-portable. */
 		error_ = strerror_r(-errcode, error, sizeof(error));
 		if (error_ != error) {
 			strncpy(error, error_, sizeof(error));
 			error[sizeof(error) - 1] = '\0';
 		}
+#else
+		/* POSIX variant */
+		if (strerror_r(-errcode, error, sizeof(error)) != 0)
+			error[0] = '\0';
+#endif
 	}
 
 	log_err(_("Command failed with code %i"), -errcode);