Commit 6c2dbff7 authored by Ganesh Ajjanagadde's avatar Ganesh Ajjanagadde

ffserver: fix incorrect strlcpy usage

Somewhat ironic that this "safe" interface is actually being used
unsafely here. This fixes the usage preventing potential null pointer
dereference, where the old code was doubly broken: ctime can return
NULL, and ctime can return an arbitrarily long buffer.
Reviewed-by: 's avatarMark Harris <mark.hsj@gmail.com>
Reviewed-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
Signed-off-by: 's avatarGanesh Ajjanagadde <gajjanagadde@gmail.com>
parent cf491a92
...@@ -305,15 +305,19 @@ static void ffm_set_write_index(AVFormatContext *s, int64_t pos, ...@@ -305,15 +305,19 @@ static void ffm_set_write_index(AVFormatContext *s, int64_t pos,
ffm->file_size = file_size; ffm->file_size = file_size;
} }
static char *ctime1(char *buf2, int buf_size) static char *ctime1(char *buf2, size_t buf_size)
{ {
time_t ti; time_t ti;
char *p; char *p;
ti = time(NULL); ti = time(NULL);
p = ctime(&ti); p = ctime(&ti);
if (!p || !*p) {
*buf2 = '\0';
return buf2;
}
av_strlcpy(buf2, p, buf_size); av_strlcpy(buf2, p, buf_size);
p = buf2 + strlen(p) - 1; p = buf2 + strlen(buf2) - 1;
if (*p == '\n') if (*p == '\n')
*p = '\0'; *p = '\0';
return buf2; return buf2;
......
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