blob: 784b4fc6c599fadcc5b4988cd681769a84c2acb8 [file] [log] [blame]
Brad Bishop15ae2502019-06-18 21:44:24 -04001From e86a259e1ce19c70ecfdece69ab53a07c63a34e1 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
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012index c81b4c13..7a403640 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 }