Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
slurm.32313
U_04-Use-safe_xcalloc.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File U_04-Use-safe_xcalloc.patch of Package slurm.32313
From: Tim Wickberg <tim@schedmd.com> Date: Tue Nov 28 17:31:52 2023 -0700 Subject: [PATCH 4/28]Use safe_xcalloc(). Patch-mainline: Upstream Git-repo: https://github.com/SchedMD/slurm Git-commit: 08aa5b89326cbc1e2bd195ddfcb600226ffdd679 References: bsc#1218046, bsc#1218050, bsc#1218051, bsc#1218053 Signed-off-by: Egbert Eich <eich@suse.de> --- src/common/pack.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/common/pack.c b/src/common/pack.c index dc05ce6e12..e703360649 100644 --- a/src/common/pack.c +++ b/src/common/pack.c @@ -532,12 +532,15 @@ int unpack16_array(uint16_t ** valp, uint32_t * size_val, Buf buffer) if ((*size_val) > MAX_ARRAY_LEN_MEDIUM) return SLURM_ERROR; - *valp = xmalloc_nz((*size_val) * sizeof(uint16_t)); + safe_xcalloc(*valp, *size_val, sizeof(uint16_t)); for (i = 0; i < *size_val; i++) { if (unpack16((*valp) + i, buffer)) - return SLURM_ERROR; + goto unpack_error; } return SLURM_SUCCESS; + +unpack_error: + return SLURM_ERROR; } /* @@ -568,12 +571,15 @@ int unpack32_array(uint32_t ** valp, uint32_t * size_val, Buf buffer) if ((*size_val) > MAX_ARRAY_LEN_LARGE) return SLURM_ERROR; - *valp = xmalloc_nz((*size_val) * sizeof(uint32_t)); + safe_xcalloc(*valp, *size_val, sizeof(uint32_t)); for (i = 0; i < *size_val; i++) { if (unpack32((*valp) + i, buffer)) - return SLURM_ERROR; + goto unpack_error; } return SLURM_SUCCESS; + +unpack_error: + return SLURM_ERROR; } /* @@ -620,12 +626,15 @@ int unpack64_array(uint64_t ** valp, uint32_t * size_val, Buf buffer) if ((*size_val) > MAX_ARRAY_LEN_MEDIUM) return SLURM_ERROR; - *valp = xmalloc_nz((*size_val) * sizeof(uint64_t)); + safe_xcalloc(*valp, *size_val, sizeof(uint64_t)); for (i = 0; i < *size_val; i++) { if (unpack64((*valp) + i, buffer)) - return SLURM_ERROR; + goto unpack_error; } return SLURM_SUCCESS; + +unpack_error: + return SLURM_ERROR; } /* @@ -672,12 +681,15 @@ int unpackdouble_array(double **valp, uint32_t* size_val, Buf buffer) if ((*size_val) > MAX_ARRAY_LEN_SMALL) return SLURM_ERROR; - *valp = xmalloc_nz((*size_val) * sizeof(double)); + safe_xcalloc(*valp, *size_val, sizeof(double)); for (i = 0; i < *size_val; i++) { if (unpackdouble((*valp) + i, buffer)) - return SLURM_ERROR; + goto unpack_error; } return SLURM_SUCCESS; + +unpack_error: + return SLURM_ERROR; } void packlongdouble_array(long double *valp, uint32_t size_val, Buf buffer) @@ -702,12 +714,15 @@ int unpacklongdouble_array(long double **valp, uint32_t* size_val, Buf buffer) if ((*size_val) > MAX_ARRAY_LEN_SMALL) return SLURM_ERROR; - *valp = xmalloc_nz((*size_val) * sizeof(long double)); + safe_xcalloc(*valp, *size_val, sizeof(long double)); for (i = 0; i < *size_val; i++) { if (unpacklongdouble((*valp) + i, buffer)) - return SLURM_ERROR; + goto unpack_error; } return SLURM_SUCCESS; + +unpack_error: + return SLURM_ERROR; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor