[vlc-commits] vlc_readdir: fix integer overflow on error

Rémi Denis-Courmont git at videolan.org
Thu Jan 9 20:13:01 CET 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jan  9 21:04:36 2014 +0200| [3dfba47808176d1c032e34166028843a4317567c] | committer: Rémi Denis-Courmont

vlc_readdir: fix integer overflow on error

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3dfba47808176d1c032e34166028843a4317567c
---

 src/posix/filesystem.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/posix/filesystem.c b/src/posix/filesystem.c
index 246133b..b4ba03a 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -158,9 +158,9 @@ char *vlc_readdir( DIR *dir )
 
     long len = fpathconf (dirfd (dir), _PC_NAME_MAX);
     /* POSIX says there shall we room for NAME_MAX bytes at all times */
-    if (/*len == -1 ||*/ len < NAME_MAX)
+    if (len == -1 || len < NAME_MAX)
         len = NAME_MAX;
-    len += offsetof (struct dirent, d_name) + 1;
+    len += sizeof (*ent) + 1 - sizeof (ent->d_name);
 
     struct dirent *buf = malloc (len);
     if (unlikely(buf == NULL))



More information about the vlc-commits mailing list