summaryrefslogtreecommitdiff
path: root/serial.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2018-02-08 19:57:11 -0800
committerGary E. Miller <gem@rellim.com>2018-02-08 19:57:11 -0800
commitb6717c857ae1013f8a5ee2d7887abb0ae06e2fc2 (patch)
tree28678c119b1bfb03b5d9ea93293b02c95b63f974 /serial.c
parentfa47f7390f183de954e9db0163e0a494fa99258e (diff)
downloadgpsd-b6717c857ae1013f8a5ee2d7887abb0ae06e2fc2.tar.gz
serial.c: make sure procentry->d_name fits in procpath
Diffstat (limited to 'serial.c')
-rw-r--r--serial.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/serial.c b/serial.c
index 0d68546f..b8a06408 100644
--- a/serial.c
+++ b/serial.c
@@ -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) {