31 lines
976 B
Diff
31 lines
976 B
Diff
From 45824723bf3968a1106089fb0572ad6a593ac62e Mon Sep 17 00:00:00 2001
|
|
From: zhongtao <taozh97@163.com>
|
|
Date: Mon, 17 Oct 2022 15:15:49 +0800
|
|
Subject: [PATCH 13/43] Add parameter check to path
|
|
|
|
Signed-off-by: zhongtao <taozh97@163.com>
|
|
---
|
|
src/utils/cutils/path.c | 6 ++++++
|
|
1 file changed, 6 insertions(+)
|
|
|
|
diff --git a/src/utils/cutils/path.c b/src/utils/cutils/path.c
|
|
index 79cd7af6..5a743632 100644
|
|
--- a/src/utils/cutils/path.c
|
|
+++ b/src/utils/cutils/path.c
|
|
@@ -733,6 +733,12 @@ int util_realpath_in_scope(const char *rootfs, const char *path, char **real_pat
|
|
char cleaned[PATH_MAX] = { 0 };
|
|
char *tmp = NULL;
|
|
|
|
+ if (rootfs == NULL || path == NULL || real_path == NULL) {
|
|
+ ERROR("Null parameter");
|
|
+ ret = -1;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
int nret = snprintf(full_path, sizeof(full_path), "%s%s", rootfs, path);
|
|
if (nret < 0 || (size_t)nret >= sizeof(full_path)) {
|
|
ERROR("sprintf error: %s", strerror(errno));
|
|
--
|
|
2.25.1
|
|
|