Commit 26db27e0 authored by Rafaël Carré's avatar Rafaël Carré

MMS: add an error message if UTF-16 conversion fails

Server rejects connection if some field are not set properly
parent d843a2fc
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#endif #endif
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_access.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include "asf.h" #include "asf.h"
...@@ -106,7 +107,7 @@ void var_buffer_addmemory( var_buffer_t *p_buf, void *p_mem, int i_mem ) ...@@ -106,7 +107,7 @@ void var_buffer_addmemory( var_buffer_t *p_buf, void *p_mem, int i_mem )
p_buf->i_data += i_mem; p_buf->i_data += i_mem;
} }
void var_buffer_addUTF16( var_buffer_t *p_buf, const char *p_str ) void var_buffer_addUTF16( access_t *p_access, var_buffer_t *p_buf, const char *p_str )
{ {
uint16_t *p_out; uint16_t *p_out;
size_t i_out; size_t i_out;
...@@ -120,7 +121,10 @@ void var_buffer_addUTF16( var_buffer_t *p_buf, const char *p_str ) ...@@ -120,7 +121,10 @@ void var_buffer_addUTF16( var_buffer_t *p_buf, const char *p_str )
else else
p_out = NULL; p_out = NULL;
if( p_out == NULL ) if( p_out == NULL )
{
msg_Err( p_access, "UTF-16 conversion failed" );
i_out = 0; i_out = 0;
}
i_out /= 2; i_out /= 2;
for( size_t i = 0; i < i_out; i ++ ) for( size_t i = 0; i < i_out; i ++ )
......
...@@ -43,7 +43,7 @@ void var_buffer_add16( var_buffer_t *p_buf, uint16_t i_word ); ...@@ -43,7 +43,7 @@ void var_buffer_add16( var_buffer_t *p_buf, uint16_t i_word );
void var_buffer_add32( var_buffer_t *p_buf, uint32_t i_word ); void var_buffer_add32( var_buffer_t *p_buf, uint32_t i_word );
void var_buffer_add64( var_buffer_t *p_buf, uint64_t i_word ); void var_buffer_add64( var_buffer_t *p_buf, uint64_t i_word );
void var_buffer_addmemory( var_buffer_t *p_buf, void *p_mem, int i_mem ); void var_buffer_addmemory( var_buffer_t *p_buf, void *p_mem, int i_mem );
void var_buffer_addUTF16( var_buffer_t *p_buf, const char *p_str ); void var_buffer_addUTF16( access_t *p_access, var_buffer_t *p_buf, const char *p_str );
void var_buffer_free( var_buffer_t *p_buf ); void var_buffer_free( var_buffer_t *p_buf );
......
...@@ -536,7 +536,7 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto ) ...@@ -536,7 +536,7 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto )
"NSPlayer/7.0.0.1956; {"GUID_FMT"}; Host: %s", "NSPlayer/7.0.0.1956; {"GUID_FMT"}; Host: %s",
GUID_PRINT( p_sys->guid ), GUID_PRINT( p_sys->guid ),
p_url->psz_host ); p_url->psz_host );
var_buffer_addUTF16( &buffer, tmp ); var_buffer_addUTF16( p_access, &buffer, tmp );
mms_CommandSend( p_access, mms_CommandSend( p_access,
0x01, /* connexion request */ 0x01, /* connexion request */
...@@ -598,7 +598,7 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto ) ...@@ -598,7 +598,7 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto )
{ {
sprintf( tmp, "\\\\192.168.0.1\\TCP\\1242" ); sprintf( tmp, "\\\\192.168.0.1\\TCP\\1242" );
} }
var_buffer_addUTF16( &buffer, tmp ); var_buffer_addUTF16( p_access, &buffer, tmp );
var_buffer_add16( &buffer, '0' ); var_buffer_add16( &buffer, '0' );
mms_CommandSend( p_access, mms_CommandSend( p_access,
...@@ -633,7 +633,7 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto ) ...@@ -633,7 +633,7 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto )
{ {
mediapath++; mediapath++;
} }
var_buffer_addUTF16( &buffer, mediapath ); var_buffer_addUTF16( p_access, &buffer, mediapath );
mms_CommandSend( p_access, mms_CommandSend( p_access,
0x05, 0x05,
......
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