Skip to content

Commit b685462

Browse files
tphung3dthain
andcommitted
TaskVine: Fix buffer null terminate (#3547)
* Must null-terminate buffer received from worker before treating as a string. * Worker source needs to be an explicit dependency. * fix * format --------- Co-authored-by: Douglas Thain <[email protected]>
1 parent 59514bb commit b685462

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

taskvine/src/worker/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ SOURCES = \
1111
vine_transfer_server.c \
1212
vine_process.c \
1313
vine_watcher.c \
14-
vine_gpus.c
14+
vine_gpus.c \
15+
vine_worker.c
1516

1617
OBJECTS = $(SOURCES:%.c=%.o)
1718
PROGRAMS = vine_worker

taskvine/src/worker/vine_worker.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -693,11 +693,16 @@ static int reap_completed_function_call(struct vine_process *p, struct link *man
693693
int len_buffer = atoi(buffer);
694694

695695
/* now read the buffer, which is the task id of the done function invocation. */
696-
char buffer_data[len_buffer];
696+
char buffer_data[len_buffer + 1];
697697
ok = link_read(p->library_read_link, buffer_data, len_buffer, time(0) + active_timeout);
698698
if (ok <= 0) {
699699
return 0;
700700
}
701+
702+
/* null terminate the buffer before treating it as a string. */
703+
buffer_data[ok] = 0;
704+
705+
/* parse out the taskid of the completed task */
701706
uint64_t done_task_id = (uint64_t)strtoul(buffer_data, NULL, 10);
702707
debug(D_VINE, "Received result for function %" PRIu64, done_task_id);
703708

0 commit comments

Comments
 (0)