diff --git a/src/common/slurm_protocol_defs.h b/src/common/slurm_protocol_defs.h index a9d3cd273a7fb3fa4c65e0229be4d58a53158701..f8cbffb86115dbcd07a7fb1183c04f311430c78c 100644 --- a/src/common/slurm_protocol_defs.h +++ b/src/common/slurm_protocol_defs.h @@ -194,6 +194,9 @@ typedef struct slurm_protocol_header { uint32_t body_length; } header_t; +/* SLURM_IO_HEADER_SIZE is the packed data structure size, *\ +\* not necessarily sizeof(slurm_io_stream_header_t) */ +#define SLURM_IO_HEADER_SIZE (SLURM_SSL_SIGNATURE_LENGTH + 8) typedef struct slurm_io_stream_header { uint16_t version; /*version/magic number */ char key[SLURM_SSL_SIGNATURE_LENGTH]; diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c index c4664630be442cbbfcc9939a96d80b76fbbcbd7e..dd84d556b421dcfe4feef3cfb7123785589df5cb 100644 --- a/src/common/slurm_protocol_pack.c +++ b/src/common/slurm_protocol_pack.c @@ -76,6 +76,8 @@ void unpack_header ( header_t * header , Buf buffer ) unpack32 ( & header -> body_length , buffer ) ; } +/* SLURM_IO_HEADER_SIZE is the packed data structure size, *\ +\* not necessarily sizeof(slurm_io_stream_header_t) */ void pack_io_stream_header ( slurm_io_stream_header_t * msg , Buf buffer ) { uint32_t tmp=SLURM_SSL_SIGNATURE_LENGTH; diff --git a/src/srun/io.c b/src/srun/io.c index db764c44c79b6ce3f9c53b8e55f9503599bc1e05..1e254b7333f283ff3b1afb14019a7936dae71978 100644 --- a/src/srun/io.c +++ b/src/srun/io.c @@ -281,7 +281,6 @@ _accept_io_stream(job_t *job, int i) int size = sizeof(addr); char buf[INET_ADDRSTRLEN]; slurm_io_stream_header_t hdr; - uint32_t len = sizeof(hdr) - 4; char *msgbuf; Buf buffer; @@ -298,9 +297,9 @@ _accept_io_stream(job_t *job, int i) sin = (struct sockaddr_in *) &addr; inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN); - msgbuf = xmalloc(len); - _readn(sd, msgbuf, len); - buffer = create_buf(msgbuf, len); + msgbuf = xmalloc(SLURM_IO_HEADER_SIZE); + _readn(sd, msgbuf, SLURM_IO_HEADER_SIZE); + buffer = create_buf(msgbuf, SLURM_IO_HEADER_SIZE); unpack_io_stream_header(&hdr, buffer); free_buf(buffer); /* NOTE: this frees msgbuf */