diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2023-06-12 15:02:33 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-06-13 09:48:46 +0200 |
commit | ce34cef71a3e6b4c2206d550b209934819ace8e4 (patch) | |
tree | 12e9a1110773c350f7368e8c7238c2803f1bca49 | |
parent | 983f2db98c2cc72b0370622e66861b54606a9ab6 (diff) | |
download | barebox-ce34cef71a3e6b4c2206d550b209934819ace8e4.tar.gz barebox-ce34cef71a3e6b4c2206d550b209934819ace8e4.tar.xz |
lib: make_directory: return -ENOMEM on allocation failure
mkdir calls strdup on the dir that's passed in, but doesn't account for
allocation failure. Have it return -ENOMEM in that case.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230612130239.1087599-13-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | lib/make_directory.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/make_directory.c b/lib/make_directory.c index 7db93ded88..59ac87e6bf 100644 --- a/lib/make_directory.c +++ b/lib/make_directory.c @@ -19,6 +19,9 @@ STATIC int make_directory(const char *dir) char c; int ret = 0; + if (!s) + return -ENOMEM; + do { c = 0; |