diff options
author | Gary E. Miller <gem@rellim.com> | 2018-02-08 19:57:11 -0800 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2018-02-08 19:57:11 -0800 |
commit | b6717c857ae1013f8a5ee2d7887abb0ae06e2fc2 (patch) | |
tree | 28678c119b1bfb03b5d9ea93293b02c95b63f974 /serial.c | |
parent | fa47f7390f183de954e9db0163e0a494fa99258e (diff) | |
download | gpsd-b6717c857ae1013f8a5ee2d7887abb0ae06e2fc2.tar.gz |
serial.c: make sure procentry->d_name fits in procpath
Diffstat (limited to 'serial.c')
-rw-r--r-- | serial.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -132,7 +132,7 @@ static int fusercount(const char *path) { DIR *procd, *fdd; struct dirent *procentry, *fdentry; - char procpath[32], fdpath[64], linkpath[64]; + char procpath[64], fdpath[64], linkpath[64]; int cnt = 0; if ((procd = opendir("/proc")) == NULL) @@ -140,8 +140,9 @@ static int fusercount(const char *path) while ((procentry = readdir(procd)) != NULL) { if (isdigit(procentry->d_name[0])==0) continue; + /* longest procentry->d_name I could find was 12 */ (void)snprintf(procpath, sizeof(procpath), - "/proc/%s/fd/", procentry->d_name); + "/proc/%.20s/fd/", procentry->d_name); if ((fdd = opendir(procpath)) == NULL) continue; while ((fdentry = readdir(fdd)) != NULL) { |