diff options
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/input_cdda.c | 51 | ||||
-rw-r--r-- | src/input/input_dvb.c | 9 | ||||
-rw-r--r-- | src/input/input_dvd.c | 45 | ||||
-rw-r--r-- | src/input/input_http.c | 45 | ||||
-rw-r--r-- | src/input/input_pvr.c | 21 | ||||
-rw-r--r-- | src/input/libreal/real.c | 2 | ||||
-rw-r--r-- | src/input/libreal/sdpplin.c | 2 | ||||
-rw-r--r-- | src/input/librtsp/rtsp.c | 2 | ||||
-rw-r--r-- | src/input/mms.c | 6 | ||||
-rw-r--r-- | src/input/mmsh.c | 4 | ||||
-rw-r--r-- | src/input/pnm.c | 4 |
11 files changed, 74 insertions, 117 deletions
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index 047916a07..92eca7559 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -1307,20 +1307,17 @@ static void _cdda_mkdir_recursive_safe(xine_t *xine, char *path) { if(p && strlen(p)) { #ifdef WIN32 - if (*buf2 != '\0') { + if (*buf2 != '\0') { #endif - - int size = strlen(buf2); - snprintf(buf2 + size, sizeof(buf2) - size, "/%s", p); - + size_t size = strlen(buf2); + snprintf(buf2 + size, sizeof(buf2) - size, "/%s", p); #ifdef WIN32 - } - else { - snprintf(buf2, sizeof(buf2), "%s", p); - } - + } + else { + snprintf(buf2, sizeof(buf2), "%s", p); + } #endif /* WIN32 */ - + _cdda_mkdir_safe(xine, buf2); } } @@ -1438,13 +1435,13 @@ static int _cdda_cddb_handle_code(char *buf) { */ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { char cdir[XINE_PATH_MAX + XINE_NAME_MAX + 1]; + size_t cdir_size = 0; DIR *dir; if(this == NULL) return 0; - memset(&cdir, 0, sizeof(cdir)); - snprintf(cdir, sizeof(cdir), "%s", this->cddb.cache_dir); + cdir_size = snprintf(cdir, sizeof(cdir), "%s", this->cddb.cache_dir); if((dir = opendir(cdir)) != NULL) { struct dirent *pdir; @@ -1452,14 +1449,12 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { while((pdir = readdir(dir)) != NULL) { char discid[9]; - memset(&discid, 0, sizeof(discid)); snprintf(discid, sizeof(discid), "%08lx", this->cddb.disc_id); if(!strcasecmp(pdir->d_name, discid)) { FILE *fd; - int size = strlen(cdir); - snprintf(cdir + size, sizeof(cdir) - size, "/%s", discid); + cdir_size += snprintf(cdir + cdir_size, sizeof(cdir) - cdir_size, "/%s", discid); if((fd = fopen(cdir, "r")) == NULL) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "input_cdda: fopen(%s) failed: %s.\n", cdir, strerror(errno)); @@ -1537,14 +1532,9 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { int nyear; y = strstr(buffer, "YEAR:"); - if(y) { - if (sscanf(y+5, "%4d", &nyear) == 1) { - char year[5]; - - snprintf(year, 5, "%d", nyear); - if (this->cddb.disc_year == NULL) - this->cddb.disc_year = strdup(year); - } + if (y && this->cddb.disc_year == NULL) { + if (sscanf(y+5, "%4d", &nyear) == 1) + asprintf(&this->cddb.disc_year, "%d", nyear); } } } @@ -1812,7 +1802,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { while (strcmp(buffer, ".")) { char buf[2048]; int tnum; - int bufsize = strlen(buffercache); + size_t bufsize = strlen(buffercache); memset(&buffer, 0, sizeof(buffer)); _cdda_cddb_socket_read(this, buffer, sizeof(buffer) - 1); @@ -1880,14 +1870,9 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { int nyear; y = strstr(buffer, "YEAR:"); - if (y) { - if (sscanf(y+5, "%4d", &nyear) == 1) { - char year[5]; - - snprintf(year, 5, "%d", nyear); - if (this->cddb.disc_year == NULL) - this->cddb.disc_year = strdup(year); - } + if (y && this->cddb.disc_year == NULL) { + if (sscanf(y+5, "%4d", &nyear) == 1) + asprintf(&this->cddb.disc_year, "%d", nyear); } } } diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c index 669cd1e14..69a413bac 100644 --- a/src/input/input_dvb.c +++ b/src/input/input_dvb.c @@ -884,7 +884,6 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch channel_t *channels = NULL; int num_channels = 0; int num_alloc = 0; - int i; struct stat st; snprintf(filename, BUFSIZE, "%s/.xine/channels.conf", xine_get_homedir()); @@ -909,8 +908,8 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch while ( fgets (str, BUFSIZE, f)) { channel_t channel = {0}; - /* lose trailing spaces & control characters */ - i = strlen (str); + /* lose trailing spaces & control characters */ + size_t i = strlen (str); while (i && str[i - 1] <= ' ') --i; if (i == 0) @@ -1660,7 +1659,7 @@ static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, char* /* The line to be printed next. */ char text_line[512]; int text_width, text_height; - int old_line_length, line_cursor; + size_t old_line_length, line_cursor; char* bound, *old_bound; *height = 0; @@ -2816,7 +2815,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen) * that the channels have really ugly names, sometimes prefixed * by numbers... */ - int chanlen = strlen(channame); + size_t chanlen = strlen(channame); int offset = 0; xprintf(this->class->xine, XINE_VERBOSITY_LOG, diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index 012d695ec..a845d7628 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -352,11 +352,14 @@ static void send_mouse_enter_leave_event(dvd_input_plugin_t *this, int direction } static int update_title_display(dvd_input_plugin_t *this) { - char ui_title[MAX_STR_LEN + 1]; - xine_event_t uevent; xine_ui_data_t data; + xine_event_t uevent = { + .type = XINE_EVENT_UI_SET_TITLE, + .stream = this->stream, + .data = &data, + .data_length = sizeof(data) + }; int tt=-1, pr=-1; - size_t ui_str_length=0; int num_tt = 0; if(!this || !(this->stream)) @@ -386,15 +389,15 @@ static int update_title_display(dvd_input_plugin_t *this) { dvdnav_get_number_of_parts(this->dvdnav, tt, &num_part); dvdnav_get_angle_info(this->dvdnav, &cur_angle, &num_angle); if(num_angle > 1) { - snprintf(ui_title, MAX_STR_LEN, - "Title %i, Chapter %i, Angle %i of %i", - tt,pr,cur_angle, num_angle); + data.str_len = snprintf(data.str, sizeof(data.str), + "Title %i, Chapter %i, Angle %i of %i", + tt,pr,cur_angle, num_angle); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,cur_angle); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,num_angle); } else { - snprintf(ui_title, MAX_STR_LEN, - "Title %i, Chapter %i", - tt,pr); + data.str_len = snprintf(data.str, sizeof(data.str), + "Title %i, Chapter %i", + tt,pr); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,0); } @@ -403,9 +406,9 @@ static int update_title_display(dvd_input_plugin_t *this) { _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_NUMBER,pr); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_COUNT,num_part); } else if (tt == 0 && dvdnav_menu_table[pr]) { - snprintf(ui_title, MAX_STR_LEN, - "DVD %s Menu", - dvdnav_menu_table[pr]); + data.str_len = snprintf(data.str, sizeof(data.str), + "DVD %s Menu", + dvdnav_menu_table[pr]); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_NUMBER,tt); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_COUNT,num_tt); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_NUMBER,0); @@ -413,7 +416,8 @@ static int update_title_display(dvd_input_plugin_t *this) { _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,0); } else { - strcpy(ui_title, "DVD Menu"); + strcpy(data.str, "DVD Menu"); + data.str_len = strlen(data.str); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_NUMBER,0); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_COUNT,num_tt); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_NUMBER,0); @@ -421,22 +425,15 @@ static int update_title_display(dvd_input_plugin_t *this) { _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0); _x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,0); } - ui_str_length = strlen(ui_title); if (this->dvd_name && this->dvd_name[0] && - (ui_str_length + strlen(this->dvd_name) < MAX_STR_LEN)) { - snprintf(ui_title+ui_str_length, MAX_STR_LEN - ui_str_length, - ", %s", this->dvd_name); + (data.str_len + strlen(this->dvd_name) < sizeof(data.str))) { + data.str_len += snprintf(data.str+data.str_len, sizeof(data.str) - data.str_len, + ", %s", this->dvd_name); } #ifdef INPUT_DEBUG - printf("input_dvd: Changing title to read '%s'\n", ui_title); + printf("input_dvd: Changing title to read '%s'\n", data.str); #endif - uevent.type = XINE_EVENT_UI_SET_TITLE; - uevent.stream = this->stream; - uevent.data = &data; - uevent.data_length = sizeof(data);; - memcpy(data.str, ui_title, strlen(ui_title) + 1); - data.str_len = strlen(ui_title) + 1; xine_event_send(this->stream, &uevent); return 1; diff --git a/src/input/input_http.c b/src/input/input_http.c index deaaa0719..dab7310c3 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -651,7 +651,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) { int done, len, linenum; int httpcode; int res; - int buflen; + size_t buflen; int use_proxy; int proxyport; int mpegurl_redirect = 0; @@ -743,43 +743,38 @@ static int http_plugin_open (input_plugin_t *this_gen ) { if (use_proxy) { if (this->port != DEFAULT_HTTP_PORT) { - snprintf (this->buf, BUFSIZE, "GET http://%s:%d%s HTTP/1.0\015\012", - this->host, this->port, this->uri); + buflen = snprintf (this->buf, BUFSIZE, "GET http://%s:%d%s HTTP/1.0\015\012", + this->host, this->port, this->uri); } else { - snprintf (this->buf, BUFSIZE, "GET http://%s%s HTTP/1.0\015\012", - this->host, this->uri); + buflen = snprintf (this->buf, BUFSIZE, "GET http://%s%s HTTP/1.0\015\012", + this->host, this->uri); } } else - snprintf (this->buf, BUFSIZE, "GET %s HTTP/1.0\015\012", this->uri); + buflen = snprintf (this->buf, BUFSIZE, "GET %s HTTP/1.0\015\012", this->uri); - buflen = strlen(this->buf); if (this->port != DEFAULT_HTTP_PORT) - snprintf (this->buf + buflen, BUFSIZE - buflen, "Host: %s:%d\015\012", - this->host, this->port); + buflen += snprintf (this->buf + buflen, BUFSIZE - buflen, "Host: %s:%d\015\012", + this->host, this->port); else - snprintf (this->buf + buflen, BUFSIZE - buflen, "Host: %s\015\012", - this->host); + buflen += snprintf (this->buf + buflen, BUFSIZE - buflen, "Host: %s\015\012", + this->host); - buflen = strlen(this->buf); if (this_class->proxyuser && strlen(this_class->proxyuser)) { - snprintf (this->buf + buflen, BUFSIZE - buflen, - "Proxy-Authorization: Basic %s\015\012", this->proxyauth); - buflen = strlen(this->buf); + buflen += snprintf (this->buf + buflen, BUFSIZE - buflen, + "Proxy-Authorization: Basic %s\015\012", this->proxyauth); } if (this->user && strlen(this->user)) { - snprintf (this->buf + buflen, BUFSIZE - buflen, - "Authorization: Basic %s\015\012", this->auth); - buflen = strlen(this->buf); + buflen += snprintf (this->buf + buflen, BUFSIZE - buflen, + "Authorization: Basic %s\015\012", this->auth); } - snprintf(this->buf + buflen, BUFSIZE - buflen, - "User-Agent: xine/%s\015\012" - "Accept: */*\015\012" - "Icy-MetaData: 1\015\012" - "\015\012", - VERSION); - buflen = strlen(this->buf); + buflen += snprintf(this->buf + buflen, BUFSIZE - buflen, + "User-Agent: xine/%s\015\012" + "Accept: */*\015\012" + "Icy-MetaData: 1\015\012" + "\015\012", + VERSION); if (_x_io_tcp_write (this->stream, this->fh, this->buf, buflen) != buflen) { _x_message(this->stream, XINE_MSG_CONNECTION_REFUSED, "couldn't send request", NULL); xprintf(this_class->xine, XINE_VERBOSITY_DEBUG, "input_http: couldn't send request\n"); diff --git a/src/input/input_pvr.c b/src/input/input_pvr.c index e5c70c64d..af6070a9e 100644 --- a/src/input/input_pvr.c +++ b/src/input/input_pvr.c @@ -504,34 +504,24 @@ static void pvr_adjust_realtime_speed(pvr_input_plugin_t *this, fifo_buffer_t *f } #define PVR_FILENAME "%s%08d_%08d.vob" -#define PVR_FILENAME_SIZE 1+8+1+8+4+1 static char *make_temp_name(pvr_input_plugin_t *this, int page) { - char *filename; - int size = strlen(this->tmp_prefix)+PVR_FILENAME_SIZE; - filename = malloc(size); - - snprintf(filename, size, PVR_FILENAME, this->tmp_prefix, this->session, page); + asprintf(&filename, PVR_FILENAME, this->tmp_prefix, this->session, page); return filename; } #define SAVE_BASE_FILENAME "ch%03d %02d-%02d-%04d %02d:%02d:%02d" -#define SAVE_BASE_FILENAME_SIZE 2+3+1+2+1+2+1+4+1+2+1+2+1+2+1 static char *make_base_save_name(int channel, time_t tm) { - struct tm rec_time; char *filename; - int size = SAVE_BASE_FILENAME_SIZE; - filename = malloc(size); - localtime_r(&tm, &rec_time); - snprintf(filename, size, SAVE_BASE_FILENAME, + asprintf(&filename, SAVE_BASE_FILENAME, channel, rec_time.tm_mon+1, rec_time.tm_mday, rec_time.tm_year+1900, rec_time.tm_hour, rec_time.tm_min, rec_time.tm_sec); @@ -539,16 +529,11 @@ static char *make_base_save_name(int channel, time_t tm) { } #define SAVE_FILENAME "%s%s_%04d.vob" -#define SAVE_FILENAME_SIZE 1+4+4+1 static char *make_save_name(pvr_input_plugin_t *this, char *base, int page) { - char *filename; - int size = strlen(this->save_prefix)+strlen(base)+SAVE_FILENAME_SIZE; - filename = malloc(size); - - snprintf(filename, size, SAVE_FILENAME, this->save_prefix, base, page); + asprintf(&filename, SAVE_FILENAME, this->save_prefix, base, page); return filename; } diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c index dc3f00105..f4698a4fb 100644 --- a/src/input/libreal/real.c +++ b/src/input/libreal/real.c @@ -313,7 +313,7 @@ static void calc_response_string (char *result, char *challenge) { void real_calc_response_and_checksum (char *response, char *chksum, char *challenge) { - int ch_len, resp_len; + size_t ch_len, resp_len; int i; char *ptr; char buf[128]; diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c index 2596391f9..4c1687d41 100644 --- a/src/input/libreal/sdpplin.c +++ b/src/input/libreal/sdpplin.c @@ -99,7 +99,7 @@ static char *nl(char *data) { static int filter(const char *in, const char *filter, char **out) { - int flen=strlen(filter); + size_t flen=strlen(filter); size_t len; if (!in) diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c index 4e17c1e57..07769064a 100644 --- a/src/input/librtsp/rtsp.c +++ b/src/input/librtsp/rtsp.c @@ -127,7 +127,7 @@ static char *rtsp_get(rtsp_t *s) { static void rtsp_put(rtsp_t *s, const char *string) { - int len=strlen(string); + size_t len=strlen(string); char *buf = malloc(sizeof(char)*len+2); lprintf(">> '%s'", string); diff --git a/src/input/mms.c b/src/input/mms.c index 97a05dd89..ab1983955 100644 --- a/src/input/mms.c +++ b/src/input/mms.c @@ -771,12 +771,10 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) { /* command 0x5 */ { mms_buffer_t command_buffer; - char *path; - int pathlen; + char *path = this->uri; + size_t pathlen = strlen(path); /* remove the first '/' */ - path = this->uri; - pathlen = strlen(path); if (pathlen > 1) { path++; pathlen--; diff --git a/src/input/mmsh.c b/src/input/mmsh.c index 2feb7c37b..4ee7ed07d 100644 --- a/src/input/mmsh.c +++ b/src/input/mmsh.c @@ -190,11 +190,9 @@ struct mmsh_s { }; static int send_command (mmsh_t *this, char *cmd) { - int length; - lprintf ("send_command:\n%s\n", cmd); - length = strlen(cmd); + const size_t length = strlen(cmd); if (_x_io_tcp_write(this->stream, this->s, cmd, length) != length) { xprintf (this->stream->xine, XINE_LOG_MSG, _("libmmsh: send error\n")); return 0; diff --git a/src/input/pnm.c b/src/input/pnm.c index 5b8aa7c42..cbd245e7b 100644 --- a/src/input/pnm.c +++ b/src/input/pnm.c @@ -415,8 +415,8 @@ static void pnm_send_request(pnm_t *p, uint32_t bandwidth) { */ static void pnm_send_response(pnm_t *p, const char *response) { - - int size=strlen(response); + /** @TODO should check that sze is always < 256 */ + size_t size=strlen(response); p->buffer[0]=0x23; p->buffer[1]=0; |