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

Rémi Denis-Courmont git at videolan.org
Fri Jan 10 17:12:59 CET 2014


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

vlc_readdir: fix integer overflow on error

(cherry picked from commit 3dfba47808176d1c032e34166028843a4317567c)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=766f872048947465c77b7f479e8dfb025fd1d486
---

 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 c5a8f88..9e40f6d 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -155,9 +155,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