Skip to content

Commit 8bc9158

Browse files
ulmnavi-desu
authored andcommitted
libeinfo.c: Fix out-of-bounds array access in _eindent
fprintf handles padding itself, so get rid of the array altogether.
1 parent 4fdb883 commit 8bc9158

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/libeinfo/libeinfo.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ _eindent(FILE * EINFO_RESTRICT stream)
459459
{
460460
char *env = getenv("EINFO_INDENT");
461461
int amount = 0;
462-
char indent[INDENT_MAX];
463462

464463
if (env) {
465464
errno = 0;
@@ -468,14 +467,9 @@ _eindent(FILE * EINFO_RESTRICT stream)
468467
amount = 0;
469468
else if (amount > INDENT_MAX)
470469
amount = INDENT_MAX;
471-
472-
if (amount > 0)
473-
memset(indent, ' ', (size_t)amount);
474470
}
475471

476-
/* Terminate it */
477-
memset(indent + amount, 0, 1);
478-
return fprintf(stream, "%s", indent);
472+
return fprintf(stream, "%*s", amount, "");
479473
}
480474

481475
static const char *

0 commit comments

Comments
 (0)