mirror of
https://github.com/kdave/btrfs-progs
synced 2025-03-22 19:06:29 +00:00
btrfs-progs: string-table: check bounds before writing to a cell
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
9cae43183e
commit
b397e0eb63
@ -18,6 +18,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "common/messages.h"
|
||||
#include "common/string-table.h"
|
||||
|
||||
/*
|
||||
@ -54,6 +55,12 @@ char *table_vprintf(struct string_table *tab, unsigned int column, unsigned int
|
||||
if (!msg)
|
||||
return NULL;
|
||||
|
||||
if (column >= tab->ncols || row >= tab->nrows) {
|
||||
error("attempt to write outside of table: col %u row %u fmt %s",
|
||||
column, row, fmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (tab->cells[idx])
|
||||
free(tab->cells[idx]);
|
||||
tab->cells[idx] = msg;
|
||||
|
Loading…
Reference in New Issue
Block a user