Skip to content

Commit

Permalink
tools: bpf_jit_disasm: check for klogctl failure
Browse files Browse the repository at this point in the history
klogctl can fail and return -ve len, so check for this and
return NULL to avoid passing a (size_t)-1 to malloc.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Colin Ian King authored and davem330 committed May 9, 2016
1 parent 810810f commit 25a5434
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/net/bpf_jit_disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ static char *get_klog_buff(unsigned int *klen)
char *buff;

len = klogctl(CMD_ACTION_SIZE_BUFFER, NULL, 0);
if (len < 0)
return NULL;

buff = malloc(len);
if (!buff)
return NULL;
Expand Down

0 comments on commit 25a5434

Please sign in to comment.