diff options
author | Daniel Stenberg <daniel@haxx.se> | 2006-08-01 09:39:01 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2006-08-01 09:39:01 +0000 |
commit | ee642859ef04b9588e654ded629224fb0756f017 (patch) | |
tree | 43323831d452d1df07ab36520939c34927fc84c6 /lib | |
parent | 9f579f12fcda284c5b9f5dd8c1581fc5cd7fa8fb (diff) |
Maciej Karpiuk fixed a crash that would occur if we passed Curl_strerror()
an unknown error number on glibc systems.
http://curl.haxx.se/bug/view.cgi?id=1532289
Diffstat (limited to 'lib')
-rw-r--r-- | lib/strerror.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/strerror.c b/lib/strerror.c index c730670c9..0309e4ff7 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2004, 2006, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2004 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -637,8 +637,11 @@ const char *Curl_strerror(struct connectdata *conn, int err) char *msg = strerror_r(err, buffer, sizeof(buffer)); /* this version of strerror_r() only *might* use the buffer we pass to the function, but it always returns the error message as a pointer, - so we must copy that string unconditionally */ - strncpy(buf, msg, max); + so we must copy that string unconditionally (if non-NULL) */ + if(msg) + strncpy(buf, msg, max); + else + snprintf(buf, max, "Unknown error %d", err); } #endif /* end of HAVE_GLIBC_STRERROR_R */ #else /* HAVE_STRERROR_R */ |