/* * Given 'buffer' pointing to a network byte order 16-bit integer * (size) and a array of strings store the number of strings in * 'size_valp' and the array of strings in valp * NOTE: valp is set to point into a newly created buffer, * the caller is responsible for calling xfree on *valp * if non-NULL (set to NULL on zero size buffer value) */ int unpackstr_array(char ***valp, uint32_t * size_valp, Buf buffer) { int i; uint32_t ns; uint32_t uint32_tmp; 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); if (*size_valp > MAX_PACK_ARRAY_LEN) { error("%s: Buffer to be unpacked is too large (%u > %u)", __func__, *size_valp, MAX_PACK_ARRAY_LEN); return SLURM_ERROR; } else if (*size_valp > 0) { *valp = xmalloc_nz(sizeof(char *) * (*size_valp + 1)); for (i = 0; i < *size_valp; i++) { if (unpackmem_xmalloc(&(*valp)[i], &uint32_tmp, buffer)) return SLURM_ERROR; } (*valp)[i] = NULL; /* NULL terminated array so that execle */ /* can detect end of array */ } else *valp = NULL; return SLURM_SUCCESS; }
static int _base_hdr_unpack_ext(Buf packbuf, char **ep_data, uint32_t *ep_len) { if (unpackmem_xmalloc(ep_data, ep_len, packbuf)) { return -EINVAL; } return 0; }