mirror of
https://github.com/kdave/btrfs-progs
synced 2025-03-24 11:56:30 +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 <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include "common/messages.h"
|
||||||
#include "common/string-table.h"
|
#include "common/string-table.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -54,6 +55,12 @@ char *table_vprintf(struct string_table *tab, unsigned int column, unsigned int
|
|||||||
if (!msg)
|
if (!msg)
|
||||||
return NULL;
|
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])
|
if (tab->cells[idx])
|
||||||
free(tab->cells[idx]);
|
free(tab->cells[idx]);
|
||||||
tab->cells[idx] = msg;
|
tab->cells[idx] = msg;
|
||||||
|
Loading…
Reference in New Issue
Block a user