From 3e43bb7ccd6c852cb9720386a1f8dc2eec177a26 Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Tue, 20 Feb 2018 19:14:36 -0400 Subject: [PATCH] Applied patches provided in Savannah bug report 49991. Fix tabs in bootlogd and avoid printing unitialized "buf" variable when consolename() fails. --- src/bootlogd.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/bootlogd.c b/src/bootlogd.c index 4f820a8..5d83482 100644 --- a/src/bootlogd.c +++ b/src/bootlogd.c @@ -362,7 +362,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len) char tmp[8]; int olen = len; int dosync = 0; - int tlen; + int tlen, opos; while (len > 0) { tmp[0] = 0; @@ -387,9 +387,17 @@ void writelog(FILE *fp, unsigned char *ptr, int len) dosync = 1; break; case '\t': - line.pos += (line.pos / 8 + 1) * 8; - if (line.pos >= (int)sizeof(line.buf)) - line.pos = sizeof(line.buf) - 1; + opos = line.pos; + line.pos += ( (line.pos / 8) + 1) * 8; + if (line.pos >= (int) sizeof(line.buf)) + line.pos = (int) sizeof(line.buf) - 1; + while (opos <= line.pos) + { + memcpy(line.buf + opos, " ", 1); + opos++; + } + line.buf[line.pos] = '\0'; + printf("%s\n", line.buf); break; case 32 ... 127: case 161 ... 255: @@ -546,7 +554,7 @@ int main(int argc, char **argv) strcpy(realcons, "/dev/vc/1"); if ((realfd = open_nb(realcons)) < 0) { - fprintf(stderr, "bootlogd: %s: %s\n", buf, strerror(errno)); + fprintf(stderr, "bootlogd: %s: %s\n", realcons, strerror(errno)); return 1; }