1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Fix get_str/get_str8() to also work if the target string is not long enough to

fit all data from the container string, and allow NULL as a string also to
simply skip the string altogether.
patch by Ronald S. Bultje, rsbultje gmail com

Originally committed as revision 9817 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Ronald S. Bultje 2007-07-28 18:02:19 +00:00 committed by Diego Biurrun
parent bd7c6fd50c
commit 28263f5f15

View File

@ -25,29 +25,31 @@
static void get_str(ByteIOContext *pb, char *buf, int buf_size) static void get_str(ByteIOContext *pb, char *buf, int buf_size)
{ {
int len, i; int len, i;
char *q; char *q, r;
len = get_be16(pb); len = get_be16(pb);
q = buf; q = buf;
for(i=0;i<len;i++) { for(i=0;i<len;i++) {
r = get_byte(pb);
if (i < buf_size - 1) if (i < buf_size - 1)
*q++ = get_byte(pb); *q++ = r;
} }
*q = '\0'; if (buf_size > 0) *q = '\0';
} }
static void get_str8(ByteIOContext *pb, char *buf, int buf_size) static void get_str8(ByteIOContext *pb, char *buf, int buf_size)
{ {
int len, i; int len, i;
char *q; char *q, r;
len = get_byte(pb); len = get_byte(pb);
q = buf; q = buf;
for(i=0;i<len;i++) { for(i=0;i<len;i++) {
r = get_byte(pb);
if (i < buf_size - 1) if (i < buf_size - 1)
*q++ = get_byte(pb); *q++ = r;
} }
*q = '\0'; if (buf_size > 0) *q = '\0';
} }
static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st,