INN commit: trunk/innd (util.c)
INN Commit
Russ_Allbery at isc.org
Fri Apr 3 18:42:01 UTC 2009
Date: Friday, April 3, 2009 @ 11:42:00
Author: iulius
Revision: 8396
Fix a segfault in innd when a NULL pointer is passed as the first
argument of MaxLength.
Thanks to Petr Novopashenniy for the bug report.
Modified:
trunk/innd/util.c
--------+
util.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
Modified: util.c
===================================================================
--- util.c 2009-04-03 18:21:36 UTC (rev 8395)
+++ util.c 2009-04-03 18:42:00 UTC (rev 8396)
@@ -45,8 +45,9 @@
/*
-** Return a short name that won't overrun our bufer or syslog's buffer.
+** Return a short name that won't overrun our buffer or syslog's buffer.
** q should either be p, or point into p where the "interesting" part is.
+** q may also be NULL.
*/
char *
MaxLength(const char *p, const char *q)
@@ -54,6 +55,12 @@
static char buff[80];
unsigned int i;
+ /* Return an empty string when p is NULL. */
+ if (p == NULL) {
+ *buff = '\0';
+ return buff;
+ }
+
/* Already short enough? */
i = strlen(p);
if (i < sizeof buff - 1) {
@@ -61,7 +68,7 @@
return Join(buff);
}
- /* Simple case of just want the begining? */
+ /* Simple case of just want the beginning? */
if (q == NULL || (unsigned)(q - p) < sizeof buff - 4) {
strlcpy(buff, p, sizeof(buff) - 3);
strlcat(buff, "...", sizeof(buff));
@@ -73,7 +80,7 @@
strlcat(buff, &p[i - 10], sizeof(buff));
}
else {
- /* Not in last 10 bytes, so use double elipses. */
+ /* Not in last 10 bytes, so use double ellipses. */
strlcpy(buff, p, sizeof(buff) - 16);
strlcat(buff, "...", sizeof(buff) - 13);
strlcat(buff, &q[-5], sizeof(buff) - 3);
More information about the inn-committers
mailing list