From d4149504575cf86fe492bf9ba1390d9ca33ab484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 19 Dec 2007 01:28:16 +0100 Subject: Use strcat, delay calculation of resp_len. --- src/input/libreal/real.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/input/libreal') diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c index 925b0fdf8..3a01e546a 100644 --- a/src/input/libreal/real.c +++ b/src/input/libreal/real.c @@ -353,10 +353,10 @@ void real_calc_response_and_checksum (char *response, char *chksum, char *challe calc_response_string (response, buf); /* add tail */ - resp_len = strlen (response); - strcpy (&response[resp_len], "01d0a8e3"); + strcat(response, "01d0a8a3"); /* calculate checksum */ + resp_len = strlen (response); for (i=0; i Date: Wed, 19 Dec 2007 01:28:54 +0100 Subject: Use a zeroed allocation for buf rather than using memset. --- src/input/libreal/real.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/input/libreal') diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c index 3a01e546a..29376868c 100644 --- a/src/input/libreal/real.c +++ b/src/input/libreal/real.c @@ -316,14 +316,13 @@ void real_calc_response_and_checksum (char *response, char *chksum, char *challe int ch_len, resp_len; int i; char *ptr; - char buf[128]; + char buf[128] = { 0, }; /* initialize return values */ memset(response, 0, 64); memset(chksum, 0, 34); /* initialize buffer */ - memset(buf, 0, 128); ptr=buf; _X_BE_32C(ptr, 0xa1e9149d); ptr+=4; -- cgit v1.2.3 From 85b0af8123c0eec0d472c304e3fee440beb7d2b9 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 19 Dec 2007 01:20:10 +0000 Subject: Add and use new functions for malloc+memcpy(+NUL-term) fragments. --- src/input/libreal/rmff.c | 30 ++++++++---------------------- src/input/libreal/sdpplin.c | 3 +-- 2 files changed, 9 insertions(+), 24 deletions(-) (limited to 'src/input/libreal') diff --git a/src/input/libreal/rmff.c b/src/input/libreal/rmff.c index 4fea74636..00f749d43 100644 --- a/src/input/libreal/rmff.c +++ b/src/input/libreal/rmff.c @@ -311,19 +311,13 @@ static rmff_mdpr_t *rmff_scan_mdpr(const char *data) { mdpr->duration=_X_BE_32(&data[36]); mdpr->stream_name_size=data[40]; - mdpr->stream_name = calloc(mdpr->stream_name_size+1, sizeof(char)); - memcpy(mdpr->stream_name, &data[41], mdpr->stream_name_size); - mdpr->stream_name[mdpr->stream_name_size]=0; + mdpr->stream_name = xine_memdup0(&data[41], mdpr->stream_name_size); mdpr->mime_type_size=data[41+mdpr->stream_name_size]; - mdpr->mime_type = calloc(mdpr->mime_type_size+1, sizeof(char)); - memcpy(mdpr->mime_type, &data[42+mdpr->stream_name_size], mdpr->mime_type_size); - mdpr->mime_type[mdpr->mime_type_size]=0; + mdpr->mime_type = xine_memdup0(&data[42+mdpr->stream_name_size], mdpr->mime_type_size); mdpr->type_specific_len=_X_BE_32(&data[42+mdpr->stream_name_size+mdpr->mime_type_size]); - mdpr->type_specific_data = calloc(mdpr->type_specific_len, sizeof(char)); - memcpy(mdpr->type_specific_data, - &data[46+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len); + mdpr->type_specific_data = xine_memdup(&data[46+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len); return mdpr; } @@ -341,24 +335,17 @@ static rmff_cont_t *rmff_scan_cont(const char *data) { lprintf("warning: unknown object version in CONT: 0x%04x\n", cont->object_version); } cont->title_len=_X_BE_16(&data[10]); - cont->title = calloc((cont->title_len+1), sizeof(char)); - memcpy(cont->title, &data[12], cont->title_len); - cont->title[cont->title_len]=0; + cont->title = xine_memdup0(&data[12], cont->title_len); pos=cont->title_len+12; cont->author_len=_X_BE_16(&data[pos]); - cont->author = calloc(cont->author_len+1, sizeof(char)); - memcpy(cont->author, &data[pos+2], cont->author_len); - cont->author[cont->author_len]=0; + cont->author = xine_memdup0(&data[pos+2], cont->author_len); pos=pos+2+cont->author_len; cont->copyright_len=_X_BE_16(&data[pos]); - cont->copyright = calloc(cont->copyright_len+1, sizeof(char)); - memcpy(cont->copyright, &data[pos+2], cont->copyright_len); + cont->copyright = xine_memdup0(&data[pos+2], cont->copyright_len); cont->copyright[cont->copyright_len]=0; pos=pos+2+cont->copyright_len; cont->comment_len=_X_BE_16(&data[pos]); - cont->comment = calloc(cont->comment_len+1, sizeof(char)); - memcpy(cont->comment, &data[pos+2], cont->comment_len); - cont->comment[cont->comment_len]=0; + cont->comment = xine_memdup0(&data[pos+2], cont->comment_len); return cont; } @@ -584,8 +571,7 @@ rmff_mdpr_t *rmff_new_mdpr( mdpr->mime_type_size=strlen(mime_type); } mdpr->type_specific_len=type_specific_len; - mdpr->type_specific_data = calloc(type_specific_len, sizeof(char)); - memcpy(mdpr->type_specific_data,type_specific_data,type_specific_len); + mdpr->type_specific_data = xine_memdup(type_specific_data,type_specific_len); mdpr->mlti_data=NULL; mdpr->size=mdpr->stream_name_size+mdpr->mime_type_size+mdpr->type_specific_len+46; diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c index 5b22e9044..054783119 100644 --- a/src/input/libreal/sdpplin.c +++ b/src/input/libreal/sdpplin.c @@ -199,8 +199,7 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) { if(filter(*data,"a=OpaqueData:buffer;",&buf)) { decoded = b64_decode(buf, decoded, &(desc->mlti_data_size)); if ( decoded != NULL ) { - desc->mlti_data = calloc(desc->mlti_data_size, sizeof(char)); - memcpy(desc->mlti_data, decoded, desc->mlti_data_size); + desc->mlti_data = xine_memdup(decoded, desc->mlti_data_size); handled=1; *data=nl(*data); lprintf("mlti_data_size: %i\n", desc->mlti_data_size); -- cgit v1.2.3 From 75b8595548ee1796fd81e2b5a0a3bc99ee74265d Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 19 Dec 2007 01:37:07 +0000 Subject: Typo. --- src/input/libreal/real.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/input/libreal') diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c index 29376868c..df604eb10 100644 --- a/src/input/libreal/real.c +++ b/src/input/libreal/real.c @@ -352,7 +352,7 @@ void real_calc_response_and_checksum (char *response, char *chksum, char *challe calc_response_string (response, buf); /* add tail */ - strcat(response, "01d0a8a3"); + strcat(response, "01d0a8e3"); /* calculate checksum */ resp_len = strlen (response); -- cgit v1.2.3 From 9da4e2dde0da695c240cf48390217ac97cb10c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 19 Dec 2007 02:59:06 +0100 Subject: Update all the code to the new headers layout. --- src/input/libreal/asmrp.c | 2 +- src/input/libreal/real.c | 4 ++-- src/input/libreal/rmff.c | 2 +- src/input/libreal/sdpplin.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/input/libreal') diff --git a/src/input/libreal/asmrp.c b/src/input/libreal/asmrp.c index f7206b583..9fc7a3867 100644 --- a/src/input/libreal/asmrp.c +++ b/src/input/libreal/asmrp.c @@ -43,7 +43,7 @@ */ #include "asmrp.h" -#include "xineutils.h" +#include #define ASMRP_SYM_NONE 0 #define ASMRP_SYM_EOF 1 diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c index 29376868c..eb8540976 100644 --- a/src/input/libreal/real.c +++ b/src/input/libreal/real.c @@ -33,8 +33,8 @@ #include "real.h" #include "asmrp.h" #include "sdpplin.h" -#include "xine_internal.h" -#include "xineutils.h" +#include +#include #include "bswap.h" #define XOR_TABLE_LEN 37 diff --git a/src/input/libreal/rmff.c b/src/input/libreal/rmff.c index 4fea74636..a15c50b23 100644 --- a/src/input/libreal/rmff.c +++ b/src/input/libreal/rmff.c @@ -27,7 +27,7 @@ #define LOG */ -#include "xineutils.h" +#include #include "bswap.h" #include "rmff.h" diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c index 5b22e9044..c81e88ac2 100644 --- a/src/input/libreal/sdpplin.c +++ b/src/input/libreal/sdpplin.c @@ -29,7 +29,7 @@ #include "rmff.h" #include "rtsp.h" #include "sdpplin.h" -#include "xineutils.h" +#include /* * Decodes base64 strings (based upon b64 package) -- cgit v1.2.3