summaryrefslogtreecommitdiff
path: root/0159-bugfix-overwriting-when-i-is-len-1.patch
diff options
context:
space:
mode:
Diffstat (limited to '0159-bugfix-overwriting-when-i-is-len-1.patch')
-rw-r--r--0159-bugfix-overwriting-when-i-is-len-1.patch31
1 files changed, 31 insertions, 0 deletions
diff --git a/0159-bugfix-overwriting-when-i-is-len-1.patch b/0159-bugfix-overwriting-when-i-is-len-1.patch
new file mode 100644
index 0000000..057da86
--- /dev/null
+++ b/0159-bugfix-overwriting-when-i-is-len-1.patch
@@ -0,0 +1,31 @@
+From 9006b2901cb17b5cf0fa3579334ddb765ac3fe11 Mon Sep 17 00:00:00 2001
+From: liuxu <liuxu156@huawei.com>
+Date: Mon, 25 Nov 2024 19:42:02 +0800
+Subject: [PATCH 01/19] bugfix:overwriting when i is len-1
+
+Signed-off-by: liuxu <liuxu156@huawei.com>
+---
+ src/daemon/modules/spec/specs.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/src/daemon/modules/spec/specs.c b/src/daemon/modules/spec/specs.c
+index 36e89343..67a47257 100644
+--- a/src/daemon/modules/spec/specs.c
++++ b/src/daemon/modules/spec/specs.c
+@@ -2779,8 +2779,11 @@ void spec_remove_mount(oci_runtime_spec *oci_spec, const char *dest)
+ for (i = 0; i < oci_spec->mounts_len; i++) {
+ if (strcmp(oci_spec->mounts[i]->destination, dest) == 0) {
+ free_defs_mount(oci_spec->mounts[i]);
+- (void)memcpy((void **)&oci_spec->mounts[i], (void **)&oci_spec->mounts[i + 1],
+- (oci_spec->mounts_len - i - 1) * sizeof(void *));
++ oci_spec->mounts[i] = NULL;
++ if (i != oci_spec->mounts_len - 1) {
++ (void)memcpy((void **)&oci_spec->mounts[i], (void **)&oci_spec->mounts[i + 1],
++ (oci_spec->mounts_len - i - 1) * sizeof(void *));
++ }
+ oci_spec->mounts_len--;
+ return;
+ }
+--
+2.23.0
+