Skip to content

Commit 76fb807

Browse files
LemmingAvalanchegitster
authored andcommitted
column: guard against negative padding
Make sure that client code can’t pass in a negative padding by accident. Suggested-by: Rubén Justo <[email protected]> Signed-off-by: Kristoffer Haugsbakk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f2d31c6 commit 76fb807

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

column.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ void print_columns(const struct string_list *list, unsigned int colopts,
182182
{
183183
struct column_options nopts;
184184

185+
if (opts && (0 > opts->padding))
186+
BUG("padding must be non-negative");
185187
if (!list->nr)
186188
return;
187189
assert((colopts & COL_ENABLE_MASK) != COL_AUTO);
@@ -361,6 +363,8 @@ int run_column_filter(int colopts, const struct column_options *opts)
361363
{
362364
struct strvec *argv;
363365

366+
if (opts && (0 > opts->padding))
367+
BUG("padding must be non-negative");
364368
if (fd_out != -1)
365369
return -1;
366370

0 commit comments

Comments
 (0)