[vlc-devel] [PATCH 1/2] vlc_fixups: fix crash when NULL is passed to strdup() on OS/2

Rémi Denis-Courmont remi at remlab.net
Tue Dec 20 17:02:02 CET 2016


On December 20, 2016 2:37:54 PM GMT+02:00, KO Myung-Hun <komh78 at gmail.com> wrote:
>On OS/2, strdup() crashes if NULL is passed.
>
>When trying to play some clips such as
>http://www.ecomstation.co.kr/komh/testcase/svq1.mov, NULL is passed to
>psz_value of vlc_meta_AddExtra(). psz_value is passed to strdup(). As a
>result, crash occurs.
>---
> include/vlc_fixups.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
>index 3b80f9d..32ebe2a 100644
>--- a/include/vlc_fixups.h
>+++ b/include/vlc_fixups.h
>@@ -477,6 +477,10 @@ void freeaddrinfo (struct addrinfo *res);
> # ifndef EPROTO
> #  define EPROTO (ELAST + 1)
> # endif
>+
>+/* strdup() crashes if NULL is passed */
>+# include <string.h>
>+# define strdup(str) ((str) ? strdup(str) : NULL)
> #endif
> 
> /* math.h */
>-- 
>2.9.2
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

Passing NULL to strdup() is UB. Crashing is acceptable as UB. This patch does not make much sense such.

There may be a problem in call site.
-- 
Rémi Denis-Courmont


More information about the vlc-devel mailing list