Applied patches provided in Savannah bug report 49991. Fix tabs in

bootlogd and avoid printing unitialized "buf" variable when
consolename() fails.
This commit is contained in:
Jesse Smith 2018-02-20 19:14:36 -04:00
parent 3f98f493ff
commit 3e43bb7ccd

View File

@ -362,7 +362,7 @@ void writelog(FILE *fp, unsigned char *ptr, int len)
char tmp[8]; char tmp[8];
int olen = len; int olen = len;
int dosync = 0; int dosync = 0;
int tlen; int tlen, opos;
while (len > 0) { while (len > 0) {
tmp[0] = 0; tmp[0] = 0;
@ -387,9 +387,17 @@ void writelog(FILE *fp, unsigned char *ptr, int len)
dosync = 1; dosync = 1;
break; break;
case '\t': case '\t':
line.pos += (line.pos / 8 + 1) * 8; opos = line.pos;
if (line.pos >= (int)sizeof(line.buf)) line.pos += ( (line.pos / 8) + 1) * 8;
line.pos = sizeof(line.buf) - 1; 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; break;
case 32 ... 127: case 32 ... 127:
case 161 ... 255: case 161 ... 255:
@ -546,7 +554,7 @@ int main(int argc, char **argv)
strcpy(realcons, "/dev/vc/1"); strcpy(realcons, "/dev/vc/1");
if ((realfd = open_nb(realcons)) < 0) { 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; return 1;
} }