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

Rémi Denis-Courmont git at videolan.org
Sat Feb 8 17:04:45 CET 2014


vlc/vlc-2.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb  8 17:03:54 2014 +0100| [bbbf67276b754b344b7878dd296545bdb20aee43] | committer: Felix Paul Kühne

vlc_readdir: fix integer overflow on error

Manual back-port of 3dfba47808176d1c032e34166028843a4317567c

Signed-off-by: Felix Paul Kühne <fkuehne at videolan.org>

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

 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 49d07fc..51d04a4 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -194,14 +194,14 @@ char *vlc_readdir( DIR *dir )
     long len = fpathconf (dirfd (dir), _PC_NAME_MAX);
 #ifdef 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;
 #else
     /* OS is broken. Lets assume there is no files left. */
     if (len == -1)
         return NULL;
 #endif
-    len += offsetof (struct dirent, d_name) + 1;
+    len += sizeof (*ent) + 1 - sizeof (ent->d_name);
 #else /* __OS2__ && __KLIBC__ */
     /* In the implementation of Innotek LIBC, aka kLIBC on OS/2,
      * fpathconf (_PC_NAME_MAX) is broken, and errno is set to EBADF.



More information about the vlc-commits mailing list