aboutsummaryrefslogtreecommitdiff
path: root/src/mountinfo.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-12 00:01:33 +0000
committerRoy Marples <roy@marples.name>2007-10-12 00:01:33 +0000
commit20a149b2c7bfd7e53d24d0665281c083d7362c67 (patch)
treeb195111871b8e05c584b71aed066c3990c5db2b3 /src/mountinfo.c
parente3bc6666d6d5bd8922ca10652a2d04577357fa71 (diff)
malloc over fatty buffers
Diffstat (limited to 'src/mountinfo.c')
-rw-r--r--src/mountinfo.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mountinfo.c b/src/mountinfo.c
index 061ae945..ef3f636d 100644
--- a/src/mountinfo.c
+++ b/src/mountinfo.c
@@ -237,7 +237,7 @@ static struct mntent *getmntfile (const char *file)
static char **find_mounts (struct args *args)
{
FILE *fp;
- char buffer[PATH_MAX * 3];
+ char *buffer;
char *p;
char *from;
char *to;
@@ -250,7 +250,8 @@ static char **find_mounts (struct args *args)
if ((fp = fopen ("/proc/mounts", "r")) == NULL)
eerrorx ("getmntinfo: %s", strerror (errno));
- while (fgets (buffer, sizeof (buffer), fp)) {
+ buffer = xmalloc (sizeof (char) * PATH_MAX * 3);
+ while (fgets (buffer, PATH_MAX * 3, fp)) {
netdev = -1;
p = buffer;
from = strsep (&p, " ");
@@ -265,6 +266,7 @@ static char **find_mounts (struct args *args)
process_mount (&list, args, from, to, fst, opts, netdev);
}
+ free (buffer);
fclose (fp);
return (list);