Skip to content

Commit

Permalink
AP_HAL_SITL: ensure termination of readlink-derived progname
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Jul 8, 2019
1 parent 3b0bd67 commit fe8d631
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libraries/AP_HAL_SITL/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ void dump_stack_trace()
char *p;
int n;

n = readlink("/proc/self/exe", progname, sizeof(progname));
n = readlink("/proc/self/exe", progname, sizeof(progname)-1);
if (n == -1) {
strncpy(progname, "unknown", sizeof(progname));
n = strlen(progname);
}
progname[n] = 0;

p = strrchr(progname, '/');
Expand Down

0 comments on commit fe8d631

Please sign in to comment.