Commit 90ceeec6 authored by Francois Cartegnie's avatar Francois Cartegnie

access: mmstu: check for overflows (refs #16246)

parent 3524d9e5
...@@ -447,11 +447,12 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto ) ...@@ -447,11 +447,12 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto )
var_buffer_t buffer; var_buffer_t buffer;
char *tmp; char *tmp;
uint16_t *p; const uint16_t *p;
int i_server_version; const uint8_t *p_cmdend;
int i_tool_version; uint32_t i_server_version;
int i_update_player_url; uint32_t i_tool_version;
int i_encryption_type; uint32_t i_update_player_url;
uint32_t i_encryption_type;
int i; int i;
int i_streams; int i_streams;
int i_first; int i_first;
...@@ -554,11 +555,20 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto ) ...@@ -554,11 +555,20 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto )
i_update_player_url = GetDWLE( p_sys->p_cmd + MMS_CMD_HEADERSIZE + 40 ); i_update_player_url = GetDWLE( p_sys->p_cmd + MMS_CMD_HEADERSIZE + 40 );
i_encryption_type = GetDWLE( p_sys->p_cmd + MMS_CMD_HEADERSIZE + 44 ); i_encryption_type = GetDWLE( p_sys->p_cmd + MMS_CMD_HEADERSIZE + 44 );
p = (uint16_t*)( p_sys->p_cmd + MMS_CMD_HEADERSIZE + 48 ); p = (uint16_t*)( p_sys->p_cmd + MMS_CMD_HEADERSIZE + 48 );
p_cmdend = &p_sys->p_cmd[p_sys->i_cmd];
#define GETUTF16( psz, size ) \ #define GETUTF16( psz, size ) \
{ \ if( (UINT32_MAX == size) || \
int i; \ ((uintptr_t) p / sizeof(uint16_t) < size) || \
psz = xmalloc( size + 1); \ ((UINTPTR_MAX - (uintptr_t) p_cmdend) / sizeof(uint16_t)) < size )\
for( i = 0; i < size; i++ ) \ {\
var_buffer_free( &buffer );\
MMSClose( p_access );\
return VLC_EBADVAR;\
}\
if( (psz = malloc(size + 1)) )\
{\
for( size_t i = 0; i < size; i++ ) \
{ \ { \
psz[i] = p[i]; \ psz[i] = p[i]; \
} \ } \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment