blob: 9ae1a8e6b811adb6e119d21c67991a235b6d268d [file] [log] [blame]
Patrick Williams2194f502022-10-16 14:26:09 -05001From 921621a098f242953117747f5852d7e3136ae6c4 Mon Sep 17 00:00:00 2001
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 13 Jun 2018 23:16:53 -0700
4Subject: [PATCH] use posix strerror_r unless on gnu libc system
5
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7---
8 open-vm-tools/lib/err/errPosix.c | 9 ++++++---
9 1 file changed, 6 insertions(+), 3 deletions(-)
10
Brad Bishop15ae2502019-06-18 21:44:24 -040011diff --git a/open-vm-tools/lib/err/errPosix.c b/open-vm-tools/lib/err/errPosix.c
Patrick Williams2194f502022-10-16 14:26:09 -050012index c81b4c13f..7a4036402 100644
Brad Bishop15ae2502019-06-18 21:44:24 -040013--- a/open-vm-tools/lib/err/errPosix.c
14+++ b/open-vm-tools/lib/err/errPosix.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080015@@ -31,6 +31,7 @@
16 #include <errno.h>
17 #include <string.h>
18 #include <locale.h>
19+#include <stdio.h>
20
21 #include "vmware.h"
22 #include "errInt.h"
23@@ -63,11 +64,13 @@ ErrErrno2String(Err_Number errorNumber, // IN
24 {
25 char *p;
26
27-#if defined(__linux__) && !defined(__ANDROID__)
28+#if defined(__GLIBC__) && !defined(__ANDROID__)
29 p = strerror_r(errorNumber, buf, bufSize);
30 #else
31- p = strerror(errorNumber);
32-#endif
33+ if (strerror_r(errorNumber, buf, bufSize) != 0)
34+ snprintf(buf, bufSize, "unknown error %i", errorNumber);
35+ p = buf;
36+#endif /* defined __GLIBC__ */
37 ASSERT(p != NULL);
38 return p;
39 }
Patrick Williams2194f502022-10-16 14:26:09 -050040--
412.25.1
42