Skip to content

Commit

Permalink
fix: Don't write trailing NUL to pidfile.
Browse files Browse the repository at this point in the history
Fixes esnet#1120.
  • Loading branch information
bmah888 committed Feb 4, 2021
1 parent fab96c1 commit 8f1efb6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* iperf, Copyright (c) 2014-2020, The Regents of the University of
* iperf, Copyright (c) 2014-2021, The Regents of the University of
* California, through Lawrence Berkeley National Laboratory (subject
* to receipt of any required approvals from the U.S. Dept. of
* Energy). All rights reserved.
Expand Down Expand Up @@ -4231,7 +4231,7 @@ iperf_create_pidfile(struct iperf_test *test)
return -1;
}
snprintf(buf, sizeof(buf), "%d", getpid()); /* no trailing newline */
if (write(fd, buf, strlen(buf) + 1) < 0) {
if (write(fd, buf, strlen(buf)) < 0) {
return -1;
}
if (close(fd) < 0) {
Expand Down

0 comments on commit 8f1efb6

Please sign in to comment.