Projects
Eulaceura:Factory
mdadm
_service:obs_scm:0024-mdadm-Monitor.c-fix-cover...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0024-mdadm-Monitor.c-fix-coverity-issues.patch of Package mdadm
From 4e9e7cc59fab61e16a93d0ae3b73e9b9b0001d4b Mon Sep 17 00:00:00 2001 From: Nigel Croxon <ncroxon@redhat.com> Date: Mon, 15 Jul 2024 10:13:46 -0400 Subject: [PATCH] mdadm: Monitor.c fix coverity issues Fixing the following coding errors the coverity tools found: * Event check_return: Calling "fcntl(fd, 2, 1)" without checking return value. This library function may fail and return an error code. * Dereferencing "sl", which is known to be "NULL". * Event fixed_size_dest: You might overrun the 32-character fixed-size string "devnm" by copying "tmp" without checking the length. Signed-off-by: Nigel Croxon <ncroxon@redhat.com> --- Monitor.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Monitor.c b/Monitor.c index 9f1765d..4637729 100644 --- a/Monitor.c +++ b/Monitor.c @@ -570,7 +570,9 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, if (!is_container && !md_array_active(fd)) goto disappeared; - fcntl(fd, F_SETFD, FD_CLOEXEC); + if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) + goto out; + if (md_get_array_info(fd, &array) < 0) goto disappeared; @@ -796,7 +798,8 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist, strcpy(st->parent_devnm, mse->metadata_version+10); sl = strchr(st->parent_devnm, '/'); - *sl = 0; + if (sl) + *sl = 0; } else st->parent_devnm[0] = 0; *statelist = st; @@ -1135,7 +1138,7 @@ int Wait(char *dev) return 2; } - strcpy(devnm, tmp); + snprintf(devnm, sizeof(devnm), "%s", tmp); while(1) { struct mdstat_ent *ms = mdstat_read(1, 0); @@ -1206,7 +1209,8 @@ int WaitClean(char *dev, int verbose) return 1; } - strcpy(devnm, fd2devnm(fd)); + snprintf(devnm, sizeof(devnm), "%s", fd2devnm(fd)); + mdi = sysfs_read(fd, devnm, GET_VERSION|GET_LEVEL|GET_SAFEMODE); if (!mdi) { if (verbose) -- 2.43.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2