summaryrefslogtreecommitdiff
path: root/src/fcstat.c
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2017-03-01 19:48:02 +0900
committerAkira TAGOH <akira@tagoh.org>2017-03-01 19:48:38 +0900
commitabdb6d658e1a16410dd1c964e365a3ebd5039e7c (patch)
tree0aa438633fc17ab7537496ee323ad385d1294074 /src/fcstat.c
parent9878b306f6c673d3d6cd9db487f67eb426cc03df (diff)
downloadfontconfig-abdb6d658e1a16410dd1c964e365a3ebd5039e7c.tar.gz
Fix the build issue on GNU/Hurd
PATH_MAX isn't defined on GNU/Hurd. according to the porting guidelines (https://www.gnu.org/software/hurd/hurd/porting/guidelines.html) allocate a memory dynamically instead of relying on the length of a string with PATH_MAX. https://bugs.freedesktop.org/show_bug.cgi?id=97512
Diffstat (limited to 'src/fcstat.c')
-rw-r--r--src/fcstat.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/fcstat.c b/src/fcstat.c
index 1734fa4..f6e1aaa 100644
--- a/src/fcstat.c
+++ b/src/fcstat.c
@@ -278,8 +278,13 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
{
#endif
struct stat statb;
- char f[PATH_MAX + 1];
+ char *f = malloc (len + 1 + dlen + 1);
+ if (!f)
+ {
+ ret = -1;
+ goto bail;
+ }
memcpy (f, dir, len);
f[len] = FC_DIR_SEPARATOR;
memcpy (&f[len + 1], files[n]->d_name, dlen);
@@ -287,11 +292,16 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
if (lstat (f, &statb) < 0)
{
ret = -1;
+ free (f);
goto bail;
}
if (S_ISDIR (statb.st_mode))
+ {
+ free (f);
goto bail;
+ }
+ free (f);
dtype = statb.st_mode;
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
}