summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xine/xineutils.h6
-rw-r--r--src/demuxers/demux_real.c12
-rw-r--r--src/input/libreal/real.c2
-rw-r--r--src/input/libreal/rmff.c30
-rw-r--r--src/input/libreal/sdpplin.c3
-rw-r--r--src/xine-utils/utils.c13
6 files changed, 32 insertions, 34 deletions
diff --git a/include/xine/xineutils.h b/include/xine/xineutils.h
index 4ff87e87c..89c62676b 100644
--- a/include/xine/xineutils.h
+++ b/include/xine/xineutils.h
@@ -633,6 +633,12 @@ void *xine_xcalloc(size_t nmemb, size_t size) XINE_MALLOC XINE_PROTECTED;
void *xine_xmalloc_aligned(size_t alignment, size_t size, void **base) XINE_PROTECTED;
/*
+ * Copy blocks of memory.
+ */
+void *xine_memdup (const void *src, size_t length) XINE_MALLOC XINE_PROTECTED;
+void *xine_memdup0 (const void *src, size_t length) XINE_MALLOC XINE_PROTECTED;
+
+/*
* Get user home directory.
*/
const char *xine_get_homedir(void) XINE_PROTECTED;
diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c
index c14be6b47..bd5bb4021 100644
--- a/src/demuxers/demux_real.c
+++ b/src/demuxers/demux_real.c
@@ -275,19 +275,13 @@ static mdpr_t *real_parse_mdpr(const char *data) {
mdpr->duration=_X_BE_32(&data[28]);
mdpr->stream_name_size=data[32];
- mdpr->stream_name=calloc(mdpr->stream_name_size+1, sizeof(char));
- memcpy(mdpr->stream_name, &data[33], mdpr->stream_name_size);
- mdpr->stream_name[(int)mdpr->stream_name_size]=0;
+ mdpr->stream_name=xine_memdup0(&data[33], mdpr->stream_name_size);
mdpr->mime_type_size=data[33+mdpr->stream_name_size];
- mdpr->mime_type=calloc(mdpr->mime_type_size+1, sizeof(char));
- memcpy(mdpr->mime_type, &data[34+mdpr->stream_name_size], mdpr->mime_type_size);
- mdpr->mime_type[(int)mdpr->mime_type_size]=0;
+ mdpr->mime_type=xine_memdup0(&data[34+mdpr->stream_name_size], mdpr->mime_type_size);
mdpr->type_specific_len=_X_BE_32(&data[34+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[38+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
+ mdpr->type_specific_data=xine_memdup(&data[38+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
lprintf("MDPR: stream number: %i\n", mdpr->stream_number);
lprintf("MDPR: maximal bit rate: %i\n", mdpr->max_bit_rate);
diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c
index eb8540976..078b12757 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);
diff --git a/src/input/libreal/rmff.c b/src/input/libreal/rmff.c
index a15c50b23..c12fff1d6 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 c81e88ac2..d58a3d1fe 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);
diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c
index 5aff537b4..63d7d343b 100644
--- a/src/xine-utils/utils.c
+++ b/src/xine-utils/utils.c
@@ -286,6 +286,19 @@ void *xine_xmalloc_aligned(size_t alignment, size_t size, void **base) {
return ptr;
}
+void *xine_memdup (const void *src, size_t length)
+{
+ void *dst = malloc (length);
+ return xine_fast_memcpy (dst, src, length);
+}
+
+void *xine_memdup0 (const void *src, size_t length)
+{
+ char *dst = xine_xmalloc (length + 1);
+ dst[length] = 0;
+ return xine_fast_memcpy (dst, src, length);
+}
+
#ifdef WIN32
/*
* Parse command line with Windows XP syntax and copy the command (argv[0]).