summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-05-07 18:06:56 +0200
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-05-07 18:06:56 +0200
commitbbb2643bdcc8fb3d7f29c11e1344286b042535bf (patch)
tree874f8a93f6afe13af796073c92a46dee774c946f
parent837822b5c6924be7fbc297bcef9639d7ada95a30 (diff)
downloadxine-lib-bbb2643bdcc8fb3d7f29c11e1344286b042535bf.tar.gz
xine-lib-bbb2643bdcc8fb3d7f29c11e1344286b042535bf.tar.bz2
Use proper string functions in place of sn?printf.
Instead of calling sprintf or snprintf with a "%s" format string, use the proper strcpy, strncpy, strdup or strndup function.
-rw-r--r--src/input/input_dvb.c5
-rw-r--r--src/input/input_dvd.c4
-rw-r--r--src/input/input_vcd.c11
-rw-r--r--src/input/vcd/xineplug_inp_vcd.c4
-rw-r--r--src/post/goom/goom_core.c4
-rw-r--r--src/xine-engine/info_helper.c7
6 files changed, 12 insertions, 23 deletions
diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c
index 0ec81026b..bccbc13be 100644
--- a/src/input/input_dvb.c
+++ b/src/input/input_dvb.c
@@ -1839,8 +1839,7 @@ static void show_program_info(int x, int y, int max_x, int max_y, int* last_y,
/*Content type and rating, if any. */
if (strlen(epg_data->content) > 3) {
-
- snprintf(buffer, 94, "%s", epg_data->content);
+ strncpy(buffer, epg_data->content, 94-1);
prog_rating = epg_data->rating;
if (prog_rating > 0) {
@@ -1870,7 +1869,7 @@ static void show_program_info(int x, int y, int max_x, int max_y, int* last_y,
/* Print the description. */
if (epg_data->description && strlen(epg_data->description) > 0) {
renderer->set_font(osd, "sans", EPG_DESCRIPTION_FONT_SIZE);
- sprintf(buffer, "%s", epg_data->description);
+ strcpy(buffer, epg_data->description);
/* If the description is not complete (i.e., there is no comma at the end),
add "..." to the end. In my locale they often seem to send incomplete description
texts :( */
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c
index ef5f1e055..012d695ec 100644
--- a/src/input/input_dvd.c
+++ b/src/input/input_dvd.c
@@ -1313,7 +1313,7 @@ static int dvd_plugin_get_optional_data (input_plugin_t *this_gen,
if(this && this->stream && this->dvdnav) {
if(!(dvdnav_is_domain_vts(this->dvdnav))) {
- sprintf(data, "%s", "menu");
+ strcpy(data, "menu");
if (channel <= 0)
return INPUT_OPTIONAL_SUCCESS;
else
@@ -1336,7 +1336,7 @@ static int dvd_plugin_get_optional_data (input_plugin_t *this_gen,
return INPUT_OPTIONAL_SUCCESS;
} else {
if(channel == -1) {
- sprintf(data, "%s", "none");
+ strcpy(data, "none");
return INPUT_OPTIONAL_SUCCESS;
}
}
diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c
index 02c2e83ab..760037e93 100644
--- a/src/input/input_vcd.c
+++ b/src/input/input_vcd.c
@@ -997,16 +997,9 @@ static xine_mrl_t **vcd_class_get_dir (input_class_t *this_gen, const char *file
memset(this->mrls[(i-1)], 0, sizeof(xine_mrl_t));
}
- if(this->mrls[(i-1)]->mrl) {
- this->mrls[(i-1)]->mrl = (char *)
- realloc(this->mrls[(i-1)]->mrl, strlen(mrl) + 1);
- }
- else {
- this->mrls[(i-1)]->mrl = (char *) xine_xmalloc(strlen(mrl) + 1);
- }
-
this->mrls[i-1]->origin = NULL;
- sprintf(this->mrls[i-1]->mrl, "%s", mrl);
+ free(this->mrls[(i-1)]->mrl);
+ this->mrls[i-1]->mrl = strdup(mrl);
this->mrls[i-1]->link = NULL;
this->mrls[i-1]->type = (0 | mrl_vcd);
diff --git a/src/input/vcd/xineplug_inp_vcd.c b/src/input/vcd/xineplug_inp_vcd.c
index d024c5bff..f4f823918 100644
--- a/src/input/vcd/xineplug_inp_vcd.c
+++ b/src/input/vcd/xineplug_inp_vcd.c
@@ -272,11 +272,9 @@ vcd_add_mrl_slot(vcd_input_class_t *this, const char *mrl, off_t size,
this->mrls[*i]->type = mrl_vcd;
this->mrls[*i]->size = size * M2F2_SECTOR_SIZE;
- this->mrls[*i]->mrl = (char *) malloc(strlen(mrl) + 1);
+ this->mrls[*i]->mrl = strdup(mrl);
if (NULL==this->mrls[*i]->mrl) {
LOG_ERR("Can't malloc %zu bytes for MRL name %s", sizeof(xine_mrl_t), mrl);
- } else {
- sprintf(this->mrls[*i]->mrl, "%s", mrl);
}
(*i)++;
}
diff --git a/src/post/goom/goom_core.c b/src/post/goom/goom_core.c
index b24f2f496..35fd7fc35 100644
--- a/src/post/goom/goom_core.c
+++ b/src/post/goom/goom_core.c
@@ -841,7 +841,7 @@ void update_message (PluginInfo *goomInfo, char *message) {
if (message) {
int i=1,j=0;
- sprintf (goomInfo->update_message.message, "%s", message);
+ strcpy(goomInfo->update_message.message, message);
for (j=0;goomInfo->update_message.message[j];j++)
if (goomInfo->update_message.message[j]=='\n')
i++;
@@ -855,8 +855,8 @@ void update_message (PluginInfo *goomInfo, char *message) {
char *ptr = msg;
int pos;
float ecart;
+ strncpy(msg, goomInfo->update_message.message, goomInfo->update_message.longueur);
message = msg;
- sprintf (msg, "%s", goomInfo->update_message.message);
while (!fin) {
while (1) {
diff --git a/src/xine-engine/info_helper.c b/src/xine-engine/info_helper.c
index 2d0ff4d8d..e6d4df7e9 100644
--- a/src/xine-engine/info_helper.c
+++ b/src/xine-engine/info_helper.c
@@ -340,11 +340,10 @@ void _x_meta_info_set_utf8(xine_stream_t *stream, int info, const char *str) {
void _x_meta_info_n_set(xine_stream_t *stream, int info, const char *buf, int len) {
pthread_mutex_lock(&stream->meta_mutex);
if(meta_valid(info) && len) {
- char *str = malloc(len + 1);
+ char *str = strndup(buf, len);
- snprintf(str, len + 1 , "%s", buf);
- meta_info_set_unlocked(stream, info, (const char *) &str[0]);
- free(str);
+ meta_info_set_unlocked(stream, info, str);
+ free(str);
}
pthread_mutex_unlock(&stream->meta_mutex);
}