Commit 75e61b0e authored by Måns Rullgård's avatar Måns Rullgård

use new string functions

based on patch by Reimar Döffinger

Originally committed as revision 9401 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent fc78ce80
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "avformat.h" #include "avformat.h"
#include "avstring.h"
static int default_interrupt_cb(void); static int default_interrupt_cb(void);
...@@ -169,7 +170,7 @@ int url_get_max_packet_size(URLContext *h) ...@@ -169,7 +170,7 @@ int url_get_max_packet_size(URLContext *h)
void url_get_filename(URLContext *h, char *buf, int buf_size) void url_get_filename(URLContext *h, char *buf, int buf_size)
{ {
pstrcpy(buf, buf_size, h->filename); av_strlcpy(buf, h->filename, buf_size);
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "network.h" #include "network.h"
#include "base64.h" #include "base64.h"
#include "avstring.h"
/* XXX: POST protocol is not completely implemented because ffmpeg uses /* XXX: POST protocol is not completely implemented because ffmpeg uses
only a subset of it. */ only a subset of it. */
...@@ -72,7 +73,7 @@ static int http_open_cnx(URLContext *h) ...@@ -72,7 +73,7 @@ static int http_open_cnx(URLContext *h)
if (port > 0) { if (port > 0) {
snprintf(hoststr, sizeof(hoststr), "%s:%d", hostname, port); snprintf(hoststr, sizeof(hoststr), "%s:%d", hostname, port);
} else { } else {
pstrcpy(hoststr, sizeof(hoststr), hostname); av_strlcpy(hoststr, hostname, sizeof(hoststr));
} }
if (use_proxy) { if (use_proxy) {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "avformat.h" #include "avformat.h"
#include "avstring.h"
typedef struct { typedef struct {
int img_first; int img_first;
...@@ -182,7 +183,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) ...@@ -182,7 +183,7 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
pstrcpy(s->path, sizeof(s->path), s1->filename); av_strlcpy(s->path, s1->filename, sizeof(s->path));
s->img_number = 0; s->img_number = 0;
s->img_count = 0; s->img_count = 0;
...@@ -307,7 +308,7 @@ static int img_write_header(AVFormatContext *s) ...@@ -307,7 +308,7 @@ static int img_write_header(AVFormatContext *s)
VideoData *img = s->priv_data; VideoData *img = s->priv_data;
img->img_number = 1; img->img_number = 1;
pstrcpy(img->path, sizeof(img->path), s->filename); av_strlcpy(img->path, s->filename, sizeof(img->path));
/* find format */ /* find format */
if (s->oformat->flags & AVFMT_NOFILE) if (s->oformat->flags & AVFMT_NOFILE)
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
*/ */
#include "avformat.h" #include "avformat.h"
#include "mpegaudio.h" #include "mpegaudio.h"
#include "avstring.h"
#define ID3v2_HEADER_SIZE 10 #define ID3v2_HEADER_SIZE 10
#define ID3v1_TAG_SIZE 128 #define ID3v1_TAG_SIZE 128
...@@ -350,7 +351,7 @@ static int id3v1_parse_tag(AVFormatContext *s, const uint8_t *buf) ...@@ -350,7 +351,7 @@ static int id3v1_parse_tag(AVFormatContext *s, const uint8_t *buf)
s->track = buf[126]; s->track = buf[126];
genre = buf[127]; genre = buf[127];
if (genre <= ID3v1_GENRE_MAX) if (genre <= ID3v1_GENRE_MAX)
pstrcpy(s->genre, sizeof(s->genre), id3v1_genre_str[genre]); av_strlcpy(s->genre, id3v1_genre_str[genre], sizeof(s->genre));
return 0; return 0;
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "tree.h" #include "tree.h"
#include "nut.h" #include "nut.h"
#include "avstring.h"
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <assert.h>
...@@ -404,13 +405,13 @@ static int decode_info_header(NUTContext *nut){ ...@@ -404,13 +405,13 @@ static int decode_info_header(NUTContext *nut){
if(chapter_id==0 && !strcmp(type, "UTF-8")){ if(chapter_id==0 && !strcmp(type, "UTF-8")){
if (!strcmp(name, "Author")) if (!strcmp(name, "Author"))
pstrcpy(s->author , sizeof(s->author) , str_value); av_strlcpy(s->author , str_value, sizeof(s->author));
else if(!strcmp(name, "Title")) else if(!strcmp(name, "Title"))
pstrcpy(s->title , sizeof(s->title) , str_value); av_strlcpy(s->title , str_value, sizeof(s->title));
else if(!strcmp(name, "Copyright")) else if(!strcmp(name, "Copyright"))
pstrcpy(s->copyright, sizeof(s->copyright), str_value); av_strlcpy(s->copyright, str_value, sizeof(s->copyright));
else if(!strcmp(name, "Description")) else if(!strcmp(name, "Description"))
pstrcpy(s->comment , sizeof(s->comment) , str_value); av_strlcpy(s->comment , str_value, sizeof(s->comment));
} }
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
*/ */
#include "avformat.h" #include "avformat.h"
#include "rm.h" #include "rm.h"
#include "avstring.h"
static void get_str(ByteIOContext *pb, char *buf, int buf_size) static void get_str(ByteIOContext *pb, char *buf, int buf_size)
{ {
...@@ -175,8 +175,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, ...@@ -175,8 +175,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st,
} }
} else { } else {
st->codec->codec_id = CODEC_ID_NONE; st->codec->codec_id = CODEC_ID_NONE;
pstrcpy(st->codec->codec_name, sizeof(st->codec->codec_name), av_strlcpy(st->codec->codec_name, buf, sizeof(st->codec->codec_name));
buf);
} }
if (read_all) { if (read_all) {
get_byte(pb); get_byte(pb);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> /* for select() prototype */ #include <unistd.h> /* for select() prototype */
#include "network.h" #include "network.h"
#include "avstring.h"
#include "rtp_internal.h" #include "rtp_internal.h"
...@@ -405,11 +406,11 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, ...@@ -405,11 +406,11 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
} }
break; break;
case 's': case 's':
pstrcpy(s->title, sizeof(s->title), p); av_strlcpy(s->title, p, sizeof(s->title));
break; break;
case 'i': case 'i':
if (s->nb_streams == 0) { if (s->nb_streams == 0) {
pstrcpy(s->comment, sizeof(s->comment), p); av_strlcpy(s->comment, p, sizeof(s->comment));
break; break;
} }
break; break;
...@@ -456,7 +457,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, ...@@ -456,7 +457,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
} }
} }
/* put a default control url */ /* put a default control url */
pstrcpy(rtsp_st->control_url, sizeof(rtsp_st->control_url), s->filename); av_strlcpy(rtsp_st->control_url, s->filename, sizeof(rtsp_st->control_url));
break; break;
case 'a': case 'a':
if (strstart(p, "control:", &p) && s->nb_streams > 0) { if (strstart(p, "control:", &p) && s->nb_streams > 0) {
...@@ -469,10 +470,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, ...@@ -469,10 +470,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
url_split(proto, sizeof(proto), NULL, 0, NULL, 0, NULL, NULL, 0, p); url_split(proto, sizeof(proto), NULL, 0, NULL, 0, NULL, NULL, 0, p);
if (proto[0] == '\0') { if (proto[0] == '\0') {
/* relative control URL */ /* relative control URL */
pstrcat(rtsp_st->control_url, sizeof(rtsp_st->control_url), "/"); av_strlcat(rtsp_st->control_url, "/", sizeof(rtsp_st->control_url));
pstrcat(rtsp_st->control_url, sizeof(rtsp_st->control_url), p); av_strlcat(rtsp_st->control_url, p, sizeof(rtsp_st->control_url));
} else { } else {
pstrcpy(rtsp_st->control_url, sizeof(rtsp_st->control_url), p); av_strlcpy(rtsp_st->control_url, p, sizeof(rtsp_st->control_url));
} }
} else if (strstart(p, "rtpmap:", &p)) { } else if (strstart(p, "rtpmap:", &p)) {
/* NOTE: rtpmap is only supported AFTER the 'm=' tag */ /* NOTE: rtpmap is only supported AFTER the 'm=' tag */
...@@ -749,14 +750,14 @@ static void rtsp_send_cmd(AVFormatContext *s, ...@@ -749,14 +750,14 @@ static void rtsp_send_cmd(AVFormatContext *s,
memset(reply, 0, sizeof(RTSPHeader)); memset(reply, 0, sizeof(RTSPHeader));
rt->seq++; rt->seq++;
pstrcpy(buf, sizeof(buf), cmd); av_strlcpy(buf, cmd, sizeof(buf));
snprintf(buf1, sizeof(buf1), "CSeq: %d\r\n", rt->seq); snprintf(buf1, sizeof(buf1), "CSeq: %d\r\n", rt->seq);
pstrcat(buf, sizeof(buf), buf1); av_strlcat(buf, buf1, sizeof(buf));
if (rt->session_id[0] != '\0' && !strstr(cmd, "\nIf-Match:")) { if (rt->session_id[0] != '\0' && !strstr(cmd, "\nIf-Match:")) {
snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id); snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id);
pstrcat(buf, sizeof(buf), buf1); av_strlcat(buf, buf1, sizeof(buf));
} }
pstrcat(buf, sizeof(buf), "\r\n"); av_strlcat(buf, "\r\n", sizeof(buf));
#ifdef DEBUG #ifdef DEBUG
printf("Sending:\n%s--\n", buf); printf("Sending:\n%s--\n", buf);
#endif #endif
...@@ -795,14 +796,14 @@ static void rtsp_send_cmd(AVFormatContext *s, ...@@ -795,14 +796,14 @@ static void rtsp_send_cmd(AVFormatContext *s,
reply->status_code = atoi(buf1); reply->status_code = atoi(buf1);
} else { } else {
rtsp_parse_line(reply, p); rtsp_parse_line(reply, p);
pstrcat(rt->last_reply, sizeof(rt->last_reply), p); av_strlcat(rt->last_reply, p, sizeof(rt->last_reply));
pstrcat(rt->last_reply, sizeof(rt->last_reply), "\n"); av_strlcat(rt->last_reply, "\n", sizeof(rt->last_reply));
} }
line_count++; line_count++;
} }
if (rt->session_id[0] == '\0' && reply->session_id[0] != '\0') if (rt->session_id[0] == '\0' && reply->session_id[0] != '\0')
pstrcpy(rt->session_id, sizeof(rt->session_id), reply->session_id); av_strlcpy(rt->session_id, reply->session_id, sizeof(rt->session_id));
content_length = reply->content_length; content_length = reply->content_length;
if (content_length > 0) { if (content_length > 0) {
...@@ -947,7 +948,7 @@ static int rtsp_read_header(AVFormatContext *s, ...@@ -947,7 +948,7 @@ static int rtsp_read_header(AVFormatContext *s,
rtp_opened: rtp_opened:
port = rtp_get_local_port(rtsp_st->rtp_handle); port = rtp_get_local_port(rtsp_st->rtp_handle);
if (transport[0] != '\0') if (transport[0] != '\0')
pstrcat(transport, sizeof(transport), ","); av_strlcat(transport, ",", sizeof(transport));
snprintf(transport + strlen(transport), sizeof(transport) - strlen(transport) - 1, snprintf(transport + strlen(transport), sizeof(transport) - strlen(transport) - 1,
"RTP/AVP/UDP;unicast;client_port=%d-%d", "RTP/AVP/UDP;unicast;client_port=%d-%d",
port, port + 1); port, port + 1);
...@@ -956,14 +957,14 @@ static int rtsp_read_header(AVFormatContext *s, ...@@ -956,14 +957,14 @@ static int rtsp_read_header(AVFormatContext *s,
/* RTP/TCP */ /* RTP/TCP */
else if (protocol_mask & (1 << RTSP_PROTOCOL_RTP_TCP)) { else if (protocol_mask & (1 << RTSP_PROTOCOL_RTP_TCP)) {
if (transport[0] != '\0') if (transport[0] != '\0')
pstrcat(transport, sizeof(transport), ","); av_strlcat(transport, ",", sizeof(transport));
snprintf(transport + strlen(transport), sizeof(transport) - strlen(transport) - 1, snprintf(transport + strlen(transport), sizeof(transport) - strlen(transport) - 1,
"RTP/AVP/TCP"); "RTP/AVP/TCP");
} }
else if (protocol_mask & (1 << RTSP_PROTOCOL_RTP_UDP_MULTICAST)) { else if (protocol_mask & (1 << RTSP_PROTOCOL_RTP_UDP_MULTICAST)) {
if (transport[0] != '\0') if (transport[0] != '\0')
pstrcat(transport, sizeof(transport), ","); av_strlcat(transport, ",", sizeof(transport));
snprintf(transport + strlen(transport), snprintf(transport + strlen(transport),
sizeof(transport) - strlen(transport) - 1, sizeof(transport) - strlen(transport) - 1,
"RTP/AVP/UDP;multicast"); "RTP/AVP/UDP;multicast");
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "avformat.h" #include "avformat.h"
#include "allformats.h" #include "allformats.h"
#include "opt.h" #include "opt.h"
#include "avstring.h"
#undef NDEBUG #undef NDEBUG
#include <assert.h> #include <assert.h>
...@@ -362,7 +363,7 @@ int av_open_input_stream(AVFormatContext **ic_ptr, ...@@ -362,7 +363,7 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
ic->pb = *pb; ic->pb = *pb;
ic->duration = AV_NOPTS_VALUE; ic->duration = AV_NOPTS_VALUE;
ic->start_time = AV_NOPTS_VALUE; ic->start_time = AV_NOPTS_VALUE;
pstrcpy(ic->filename, sizeof(ic->filename), filename); av_strlcpy(ic->filename, filename, sizeof(ic->filename));
/* allocate private data */ /* allocate private data */
if (fmt->priv_data_size > 0) { if (fmt->priv_data_size > 0) {
...@@ -2840,7 +2841,7 @@ void url_split(char *proto, int proto_size, ...@@ -2840,7 +2841,7 @@ void url_split(char *proto, int proto_size,
} }
if (port_ptr) if (port_ptr)
*port_ptr = port; *port_ptr = port;
pstrcpy(path, path_size, p); av_strlcpy(path, p, path_size);
} }
void av_set_pts_info(AVStream *s, int pts_wrap_bits, void av_set_pts_info(AVStream *s, int pts_wrap_bits,
......
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