44 lines
1.1 KiB
Diff
44 lines
1.1 KiB
Diff
|
From da7aecdf25371e1476da4ec56e9ec5ddf13af5da Mon Sep 17 00:00:00 2001
|
||
|
From: Nigel Croxon <ncroxon@redhat.com>
|
||
|
Date: Tue, 16 Jul 2024 07:20:10 -0400
|
||
|
Subject: [PATCH 125/201] mdadm: lib.c fix coverity issues
|
||
|
|
||
|
Fixing the following coding errors the coverity tools found:
|
||
|
|
||
|
* Event fixed_size_dest: You might overrun the 32-character fixed-size
|
||
|
string "devnm" by copying "cp + 1" without checking the length.
|
||
|
|
||
|
* Event fixed_size_dest: You might overrun the 32-character fixed-size
|
||
|
string "devnm" by copying "cp" without checking the length.
|
||
|
|
||
|
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
|
||
|
---
|
||
|
lib.c | 4 ++--
|
||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/lib.c b/lib.c
|
||
|
index 2b09293c..13d4e4f1 100644
|
||
|
--- a/lib.c
|
||
|
+++ b/lib.c
|
||
|
@@ -109,7 +109,7 @@ char *devid2kname(dev_t devid)
|
||
|
link[n] = 0;
|
||
|
cp = strrchr(link, '/');
|
||
|
if (cp) {
|
||
|
- strcpy(devnm, cp + 1);
|
||
|
+ snprintf(devnm, sizeof(devnm), "%s", cp + 1);
|
||
|
return devnm;
|
||
|
}
|
||
|
}
|
||
|
@@ -159,7 +159,7 @@ char *devid2devnm(dev_t devid)
|
||
|
ep = strchr(cp, '/');
|
||
|
if (ep)
|
||
|
*ep = 0;
|
||
|
- strcpy(devnm, cp);
|
||
|
+ snprintf(devnm, sizeof(devnm), "%s", cp);
|
||
|
return devnm;
|
||
|
}
|
||
|
}
|
||
|
--
|
||
|
2.41.0
|
||
|
|