From: Adam Dickmeiss Date: Tue, 5 Jun 2007 05:58:16 +0000 (+0000) Subject: Fixed potential buffer overrun in yaz_log for YLOG_ERRNO messages. X-Git-Tag: YAZ.3.0.10~57 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=bbc595bc456f198198ae96af6aa8b86ae2721e36;p=yaz-moved-to-github.git Fixed potential buffer overrun in yaz_log for YLOG_ERRNO messages. --- diff --git a/src/log.c b/src/log.c index ab87c32..f358690 100644 --- a/src/log.c +++ b/src/log.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: log.c,v 1.51 2007-05-06 20:12:20 adam Exp $ + * $Id: log.c,v 1.52 2007-06-05 05:58:16 adam Exp $ */ /** @@ -439,9 +439,13 @@ void yaz_log(int level, const char *fmt, ...) if (o_level & YLOG_ERRNO) { - strcat(buf, " ["); - yaz_strerror(buf+strlen(buf), 2048); - strcat(buf, "]"); + int remain = sizeof(buf) - strlen(buf); + if (remain > 100) /* reasonable minimum space for error */ + { + strcat(buf, " ["); + yaz_strerror(buf+strlen(buf), remain-5); /* 5 due to extra [] */ + strcat(buf, "]"); + } } va_end (ap); if (start_hook_func)