lkml.org 
[lkml]   [2022]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next] libbpf: Add additional null-pointer checking in make_parent_dir
Date
The make_parent_dir is called without null-pointer checking for path,
such as bpf_link__pin. To ensure there is no null-pointer dereference
in make_parent_dir, so make_parent_dir requires additional null-pointer
checking for path.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
tools/lib/bpf/libbpf.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index b53e51884f9e..5786e6184bf5 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -7634,6 +7634,9 @@ static int make_parent_dir(const char *path)
char *dname, *dir;
int err = 0;

+ if (path == NULL)
+ return -EINVAL;
+
dname = strdup(path);
if (dname == NULL)
return -ENOMEM;
--
2.25.1
\
 
 \ /
  Last update: 2022-04-21 15:01    [W:0.056 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site