Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
slurm.32299
U_17-Use-safe_unpack32.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File U_17-Use-safe_unpack32.patch of Package slurm.32299
From: Tim Wickberg <tim@schedmd.com> Date: Wed Nov 29 15:26:20 2023 -0700 Subject: [PATCH 17/28]Use safe_unpack32(). Patch-mainline: Upstream Git-repo: https://github.com/SchedMD/slurm Git-commit: a90c9a886a35ed3779fe59200dd6bd2505d51cb9 References: bsc#1218046, bsc#1218050, bsc#1218051, bsc#1218053 Signed-off-by: Egbert Eich <eich@suse.de> Signed-off-by: Egbert Eich <eich@suse.com> --- src/common/pack.c | 49 +++++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/src/common/pack.c b/src/common/pack.c index dbeca17067..cc27ab5b14 100644 --- a/src/common/pack.c +++ b/src/common/pack.c @@ -851,14 +851,7 @@ void packmem(char *valp, uint32_t size_val, Buf buffer) */ int unpackmem_ptr(char **valp, uint32_t * size_valp, Buf buffer) { - uint32_t ns; - - if (remaining_buf(buffer) < sizeof(ns)) - return SLURM_ERROR; - - memcpy(&ns, &buffer->head[buffer->processed], sizeof(ns)); - *size_valp = ntohl(ns); - buffer->processed += sizeof(ns); + safe_unpack32(size_valp, buffer); if (*size_valp > MAX_ARRAY_LEN_LARGE) { error("%s: Buffer to be unpacked is too large (%u > %u)", @@ -873,6 +866,9 @@ int unpackmem_ptr(char **valp, uint32_t * size_valp, Buf buffer) } else *valp = NULL; return SLURM_SUCCESS; + +unpack_error: + return SLURM_ERROR; } @@ -921,14 +917,7 @@ int unpackmem(char *valp, uint32_t * size_valp, Buf buffer) */ int unpackmem_xmalloc(char **valp, uint32_t * size_valp, Buf buffer) { - uint32_t ns; - - if (remaining_buf(buffer) < sizeof(ns)) - return SLURM_ERROR; - - memcpy(&ns, &buffer->head[buffer->processed], sizeof(ns)); - *size_valp = ntohl(ns); - buffer->processed += sizeof(ns); + safe_unpack32(size_valp, buffer); if (*size_valp > MAX_ARRAY_LEN_LARGE) { error("%s: Buffer to be unpacked is too large (%u > %u)", @@ -945,6 +934,9 @@ int unpackmem_xmalloc(char **valp, uint32_t * size_valp, Buf buffer) } else *valp = NULL; return SLURM_SUCCESS; + +unpack_error: + return SLURM_ERROR; } /* @@ -958,15 +950,9 @@ int unpackmem_xmalloc(char **valp, uint32_t * size_valp, Buf buffer) */ int unpackmem_malloc(char **valp, uint32_t * size_valp, Buf buffer) { - uint32_t ns; - - if (remaining_buf(buffer) < sizeof(ns)) - return SLURM_ERROR; + safe_unpack32(size_valp, buffer); - memcpy(&ns, &buffer->head[buffer->processed], sizeof(ns)); - *size_valp = ntohl(ns); - buffer->processed += sizeof(ns); - if (*size_valp > MAX_ARRAY_LEN_SMALL) { + if (*size_valp > MAX_PACK_MEM_LEN) { error("%s: Buffer to be unpacked is too large (%u > %u)", __func__, *size_valp, MAX_ARRAY_LEN_SMALL); return SLURM_ERROR; @@ -985,6 +971,9 @@ int unpackmem_malloc(char **valp, uint32_t * size_valp, Buf buffer) } else *valp = NULL; return SLURM_SUCCESS; + +unpack_error: + return SLURM_ERROR; } /* @@ -1003,14 +992,7 @@ int unpackmem_malloc(char **valp, uint32_t * size_valp, Buf buffer) */ int unpackstr_xmalloc_escaped(char **valp, uint32_t *size_valp, Buf buffer) { - uint32_t ns; - - if (remaining_buf(buffer) < sizeof(ns)) - return SLURM_ERROR; - - memcpy(&ns, &buffer->head[buffer->processed], sizeof(ns)); - *size_valp = ntohl(ns); - buffer->processed += sizeof(ns); + safe_unpack32(size_valp, buffer); if (*size_valp > MAX_PACK_MEM_LEN) { error("%s: Buffer to be unpacked is too large (%u > %u)", @@ -1049,6 +1031,9 @@ int unpackstr_xmalloc_escaped(char **valp, uint32_t *size_valp, Buf buffer) } else *valp = NULL; return SLURM_SUCCESS; + +unpack_error: + return SLURM_ERROR; } int unpackstr_xmalloc_chooser(char **valp, uint32_t *size_valp, Buf buf)
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