From efa0460c98911940d402d5117860e7133b4be4d7 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sun, 10 Mar 2002 23:07:01 +0000 Subject: [PATCH] (error_message): do not call strerror with a negative error git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10865 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/com_err/com_err.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/com_err/com_err.c b/lib/com_err/com_err.c index 2dfb758c2..8159c948b 100644 --- a/lib/com_err/com_err.c +++ b/lib/com_err/com_err.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2002 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -49,8 +49,12 @@ error_message (long code) { static char msg[128]; const char *p = com_right(_et_list, code); - if (p == NULL) - p = strerror(code); + if (p == NULL) { + if (code < 0) + sprintf(msg, "Unknown error %ld", code); + else + p = strerror(code); + } if (p != NULL && *p != '\0') { strncpy(msg, p, sizeof(msg) - 1); msg[sizeof(msg) - 1] = 0;