Fix some strlcpy() misuse that cuts off the last character of the copied

string.
Clean up some log messages.
This commit is contained in:
Nicholas J. Kain
2010-11-12 17:24:54 -05:00
parent f4a00f3826
commit 9d7ad2f11c
3 changed files with 9 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/* ifchd.c - interface change daemon
* Time-stamp: <2010-11-12 14:27:47 njk>
* Time-stamp: <2010-11-12 17:22:34 njk>
*
* (C) 2004-2010 Nicholas J. Kain <njkain at gmail dot com>
*
@@ -357,7 +357,7 @@ static int stream_onto_list(int i)
curl[i]->str = xmalloc(e - s + 1);
strlcpy(curl[i]->str, ibuf[i] + s, e - s);
strlcpy(curl[i]->str, ibuf[i] + s, e - s + 1);
last[i] = curl[i];
s = e + 1;
}
@@ -378,6 +378,8 @@ static void execute_list(int i)
p = curl[i]->str;
log_line("execute_list - p = '%s'", p);
switch (state[i]) {
case STATE_NOTHING:
if (strncmp(p, CMD_INTERFACE, sizeof(CMD_INTERFACE)) == 0)
@@ -683,7 +685,7 @@ read_again:
}
/* Append new stream input avoiding overflow. */
strlcpy(ibuf[i] + index, buf, sizeof(ibuf[i]) - index - 1);
strlcpy(ibuf[i] + index, buf, sizeof(ibuf[i]) - index);
/* Decompose ibuf contents onto strlist. */
index = stream_onto_list(i);