(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
This commit is contained in:
Assar Westerlund
2002-03-10 23:07:01 +00:00
parent c672a244ba
commit efa0460c98

View File

@@ -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;