From 54dc86f4f09f772a14f4861f38d5bae26bf5c28d Mon Sep 17 00:00:00 2001
From: Andreas Mohr <and@gmx.li>
Date: Mon, 21 Dec 2020 18:11:39 +0000
Subject: [PATCH] (treestore.c) fix copy-into-fixed-size-buffer warning
Additional ignore common value greater than oldname maxsize
found by Coverity
coverity id #32616
Signed-off-by: Andreas Mohr <and@gmx.li>
---
src/filemanager/treestore.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/filemanager/treestore.c b/src/filemanager/treestore.c
index 08354b217..630df628f 100644
a
|
b
|
tree_store_load_from (const char *name) |
264 | 264 | |
265 | 265 | common = atoi (s); |
266 | 266 | different = strtok (NULL, ""); |
267 | | if (different != NULL) |
| 267 | if (different != NULL && common < MC_MAXPATHLEN) |
268 | 268 | { |
269 | 269 | vfs_path_t *vpath; |
270 | 270 | |
271 | 271 | vpath = vfs_path_from_str (oldname); |
272 | | strcpy (oldname + common, different); |
| 272 | strncpy (oldname + common, different, MC_MAXPATHLEN - (size_t) common); |
| 273 | oldname[MC_MAXPATHLEN - 1] = '\0'; |
273 | 274 | if (vfs_file_is_local (vpath)) |
274 | 275 | { |
275 | 276 | vfs_path_t *tmp_vpath; |