Commit b76e1346 authored by Christophe Massiot's avatar Christophe Massiot

* dvblast.c: Fix segfault with buffer overflow and -d option (thanks testking...

* dvblast.c: Fix segfault with buffer overflow and -d option (thanks testking !) * ALL: Fix trailing whitespaces/tabs.
parent 392f1933
...@@ -256,7 +256,7 @@ static void demux_Handle( block_t *p_ts ) ...@@ -256,7 +256,7 @@ static void demux_Handle( block_t *p_ts )
if ( p_output != NULL ) if ( p_output != NULL )
{ {
if ( i_ca_handle && (p_output->i_config & OUTPUT_WATCH) && if ( i_ca_handle && (p_output->i_config & OUTPUT_WATCH) &&
block_UnitStart( p_ts ) ) block_UnitStart( p_ts ) )
{ {
uint8_t *p_payload; uint8_t *p_payload;
......
...@@ -145,7 +145,7 @@ static void ReadConfiguration( char *psz_file ) ...@@ -145,7 +145,7 @@ static void ReadConfiguration( char *psz_file )
ai_hints.ai_socktype = SOCK_DGRAM; ai_hints.ai_socktype = SOCK_DGRAM;
ai_hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST | AI_NUMERICSERV; ai_hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST | AI_NUMERICSERV;
ai_hints.ai_family = AF_INET6; ai_hints.ai_family = AF_INET6;
int i_ai = getaddrinfo( psz_maddr, sz_port, &ai_hints, &p_addr ); int i_ai = getaddrinfo( psz_maddr, sz_port, &ai_hints, &p_addr );
if ( i_ai != 0 ) if ( i_ai != 0 )
{ {
...@@ -473,23 +473,22 @@ int main( int i_argc, char **pp_argv ) ...@@ -473,23 +473,22 @@ int main( int i_argc, char **pp_argv )
msg_Err(NULL, "Invalid target address for -d switch"); msg_Err(NULL, "Invalid target address for -d switch");
break; break;
} }
char *psz_maddr = malloc( psz_token - optarg ); char *psz_maddr = malloc( psz_token - optarg );
memset( psz_maddr, '\0', ( psz_token - optarg ) ); memset( psz_maddr, '\0', ( psz_token - optarg ) );
strncpy( psz_maddr, optarg + 1, ( psz_token - optarg - 1 )); strncpy( psz_maddr, optarg + 1, ( psz_token - optarg - 1 ));
if ( (psz_token = strchr( psz_token, ':' )) != NULL ) if ( (psz_token = strchr( psz_token, ':' )) != NULL )
{ {
*psz_token = '\0'; *psz_token = '\0';
snprintf( sz_port, sizeof( sz_port ), "%d", atoi( psz_token + 1 ) ); snprintf( sz_port, sizeof( sz_port ), "%d", atoi( psz_token + 1 ) );
} }
memset( &ai_hints, 0, sizeof( ai_hints ) ); memset( &ai_hints, 0, sizeof( ai_hints ) );
ai_hints.ai_socktype = SOCK_DGRAM; ai_hints.ai_socktype = SOCK_DGRAM;
ai_hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST | AI_NUMERICSERV; ai_hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST | AI_NUMERICSERV;
ai_hints.ai_family = AF_INET6; ai_hints.ai_family = AF_INET6;
int i_ai = getaddrinfo( psz_maddr, sz_port, &ai_hints, &p_daddr ); int i_ai = getaddrinfo( psz_maddr, sz_port, &ai_hints, &p_daddr );
if ( i_ai != 0 ) if ( i_ai != 0 )
{ {
...@@ -503,7 +502,7 @@ int main( int i_argc, char **pp_argv ) ...@@ -503,7 +502,7 @@ int main( int i_argc, char **pp_argv )
"duplicate ([%s]:%s)", psz_maddr, sz_port ); "duplicate ([%s]:%s)", psz_maddr, sz_port );
i_dup_config |= OUTPUT_VALID; i_dup_config |= OUTPUT_VALID;
free( psz_maddr ); free( psz_maddr );
} }
else else
...@@ -528,7 +527,7 @@ int main( int i_argc, char **pp_argv ) ...@@ -528,7 +527,7 @@ int main( int i_argc, char **pp_argv )
} }
psz_displayname = malloc( INET_ADDRSTRLEN + 18 ); psz_displayname = malloc( INET_ADDRSTRLEN + 18 );
snprintf( psz_displayname, ( INET6_ADDRSTRLEN + 18 ), snprintf( psz_displayname, ( INET_ADDRSTRLEN + 18 ),
"duplicate (%s:%s)", optarg, sz_port ); "duplicate (%s:%s)", optarg, sz_port );
i_dup_config |= OUTPUT_VALID; i_dup_config |= OUTPUT_VALID;
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
#define OUTPUT_STILL_PRESENT 0x02 #define OUTPUT_STILL_PRESENT 0x02
#define OUTPUT_VALID 0x04 #define OUTPUT_VALID 0x04
#define OUTPUT_UDP 0x08 #define OUTPUT_UDP 0x08
#define OUTPUT_FILE 0x10 #define OUTPUT_FILE 0x10
typedef int64_t mtime_t; typedef int64_t mtime_t;
...@@ -69,7 +69,7 @@ typedef struct output_t ...@@ -69,7 +69,7 @@ typedef struct output_t
/* address information, protocol agnostic */ /* address information, protocol agnostic */
struct sockaddr_storage *p_addr; struct sockaddr_storage *p_addr;
socklen_t i_addrlen; socklen_t i_addrlen;
/* display string */ /* display string */
char *psz_displayname; char *psz_displayname;
......
...@@ -108,7 +108,7 @@ int output_Init( output_t *p_output, uint8_t i_config, char *psz_displayname, vo ...@@ -108,7 +108,7 @@ int output_Init( output_t *p_output, uint8_t i_config, char *psz_displayname, vo
struct addrinfo *p_ai = (struct addrinfo *)p_init_data; struct addrinfo *p_ai = (struct addrinfo *)p_init_data;
p_output->i_addrlen = p_ai->ai_addrlen; p_output->i_addrlen = p_ai->ai_addrlen;
p_output->p_addr = malloc( p_output->i_addrlen ); p_output->p_addr = malloc( p_output->i_addrlen );
memcpy( p_output->p_addr, p_ai->ai_addr, memcpy( p_output->p_addr, p_ai->ai_addr,
p_output->i_addrlen ); p_output->i_addrlen );
if ( ( p_output->i_handle = net_Open( p_output ) ) < 0 ) if ( ( p_output->i_handle = net_Open( p_output ) ) < 0 )
...@@ -178,7 +178,7 @@ static void output_Flush( output_t *p_output ) ...@@ -178,7 +178,7 @@ static void output_Flush( output_t *p_output )
if ( writev( p_output->i_handle, p_iov, i_outblocks ) < 0 ) if ( writev( p_output->i_handle, p_iov, i_outblocks ) < 0 )
{ {
msg_Err( NULL, "couldn't writev to %s (%s)", msg_Err( NULL, "couldn't writev to %s (%s)",
p_output->psz_displayname, strerror(errno) ); p_output->psz_displayname, strerror(errno) );
} }
...@@ -201,7 +201,7 @@ void output_Put( output_t *p_output, block_t *p_block ) ...@@ -201,7 +201,7 @@ void output_Put( output_t *p_output, block_t *p_block )
p_output->pp_blocks[p_output->i_depth] = p_block; p_output->pp_blocks[p_output->i_depth] = p_block;
p_output->i_depth++; p_output->i_depth++;
if ( ( ( p_output->p_addr->ss_family == AF_INET6 ) && if ( ( ( p_output->p_addr->ss_family == AF_INET6 ) &&
( p_output->i_depth >= NB_BLOCKS_IPV6 ) ) || ( p_output->i_depth >= NB_BLOCKS_IPV6 ) ) ||
( ( p_output->p_addr->ss_family == AF_INET ) && ( ( p_output->p_addr->ss_family == AF_INET ) &&
( p_output->i_depth >= NB_BLOCKS ) ) ) ( p_output->i_depth >= NB_BLOCKS ) ) )
...@@ -230,7 +230,7 @@ static int net_Open( output_t *p_output ) ...@@ -230,7 +230,7 @@ static int net_Open( output_t *p_output )
int i = i_ttl; int i = i_ttl;
setsockopt( i_handle, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, setsockopt( i_handle, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
(void *)&i, sizeof(i) ); (void *)&i, sizeof(i) );
} }
} }
else if ( p_output->p_addr->ss_family == AF_INET ) else if ( p_output->p_addr->ss_family == AF_INET )
{ {
......
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