Skip to content
Snippets Groups Projects
Commit 28950f55 authored by paun51's avatar paun51
Browse files

Fix buffer size specification in function calls

to send(), recv() and snprintf()
parent fa822f3b
No related branches found
No related tags found
1 merge request!2Fix buffer size specification in function calls
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
...@@ -138,15 +138,15 @@ static int getProcessAgentRank(uint32_t jobid, uint32_t vpid, size_t size) { ...@@ -138,15 +138,15 @@ static int getProcessAgentRank(uint32_t jobid, uint32_t vpid, size_t size) {
pid_t pid = getpid(); pid_t pid = getpid();
char info_to_send[BUFFLEN]; char info_to_send[BUFFLEN];
snprintf(info_to_send, BUFFLEN+1, snprintf(info_to_send, BUFFLEN,
"%d,%u,%u,%zu", "%d,%u,%u,%zu",
pid, vpid, jobid, size); pid, vpid, jobid, size);
if (send(socket_fd, info_to_send, BUFFLEN+1, 0) < 0) { if (send(socket_fd, info_to_send, BUFFLEN, 0) < 0) {
errorExit("send"); errorExit("send");
} }
char rank_to_recv[BUFFLEN]; char rank_to_recv[BUFFLEN];
recv(socket_fd, rank_to_recv, BUFFLEN+1, 0); recv(socket_fd, rank_to_recv, BUFFLEN, 0);
int received_rank = (int)strtol(rank_to_recv, NULL, 0); int received_rank = (int)strtol(rank_to_recv, NULL, 0);
printf("Received from server: %d\n", received_rank); printf("Received from server: %d\n", received_rank);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment