AP_HAL_SITL: ensure termination of readlink-derived progname

This commit is contained in:
Peter Barker 2019-07-05 14:10:11 +10:00 committed by Peter Barker
parent 3b0bd67afb
commit fe8d631964
1 changed files with 5 additions and 1 deletions

View File

@ -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, '/');