From: Kristoffer Haugsbakk Date: Tue, 13 Feb 2024 16:01:21 +0000 (+0100) Subject: column: guard against negative padding X-Git-Tag: v2.45.0-rc0~171^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=76fb807faacc38661ddb1c561ed80930699146ec;p=thirdparty%2Fgit.git column: guard against negative padding Make sure that client code can’t pass in a negative padding by accident. Suggested-by: Rubén Justo Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- diff --git a/column.c b/column.c index ff2f0abf39..50bbccc92e 100644 --- a/column.c +++ b/column.c @@ -182,6 +182,8 @@ void print_columns(const struct string_list *list, unsigned int colopts, { struct column_options nopts; + if (opts && (0 > opts->padding)) + BUG("padding must be non-negative"); if (!list->nr) return; assert((colopts & COL_ENABLE_MASK) != COL_AUTO); @@ -361,6 +363,8 @@ int run_column_filter(int colopts, const struct column_options *opts) { struct strvec *argv; + if (opts && (0 > opts->padding)) + BUG("padding must be non-negative"); if (fd_out != -1) return -1;