use snprintf instead of sprintf in format_movie_name to prevent OOB
This commit is contained in:
@@ -799,23 +799,23 @@ format_timestamp(char *timestamp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
format_movie_name(char *capture_fname)
|
format_movie_name(size_t size, char *capture_fname)
|
||||||
{
|
{
|
||||||
char timestamp[30];
|
char timestamp[30];
|
||||||
format_timestamp(timestamp);
|
format_timestamp(timestamp);
|
||||||
|
|
||||||
if (g_get_user_special_dir(G_USER_DIRECTORY_VIDEOS) != NULL) {
|
if (g_get_user_special_dir(G_USER_DIRECTORY_VIDEOS) != NULL) {
|
||||||
sprintf(capture_fname,
|
snprintf(capture_fname, size,
|
||||||
"%s/VID%s.mkv",
|
"%s/VID%s.mkv",
|
||||||
g_get_user_special_dir(G_USER_DIRECTORY_VIDEOS),
|
g_get_user_special_dir(G_USER_DIRECTORY_VIDEOS),
|
||||||
timestamp);
|
timestamp);
|
||||||
} else if (getenv("XDG_VIDOES_DIR") != NULL) {
|
} else if (getenv("XDG_VIDOES_DIR") != NULL) {
|
||||||
sprintf(capture_fname,
|
snprintf(capture_fname, size,
|
||||||
"%s/VID%s.mkv",
|
"%s/VID%s.mkv",
|
||||||
getenv("XDG_VIDEOS_DIR"),
|
getenv("XDG_VIDEOS_DIR"),
|
||||||
timestamp);
|
timestamp);
|
||||||
} else {
|
} else {
|
||||||
sprintf(capture_fname,
|
snprintf(capture_fname, size,
|
||||||
"%s/Videos/VID%s.mkv",
|
"%s/Videos/VID%s.mkv",
|
||||||
getenv("HOME"),
|
getenv("HOME"),
|
||||||
timestamp);
|
timestamp);
|
||||||
@@ -917,7 +917,7 @@ spawn_movie(char *cmd)
|
|||||||
void
|
void
|
||||||
on_movie_start(void)
|
on_movie_start(void)
|
||||||
{
|
{
|
||||||
format_movie_name(movie_fname);
|
format_movie_name(sizeof(movie_fname), movie_fname);
|
||||||
|
|
||||||
movie_recording = 1;
|
movie_recording = 1;
|
||||||
printf("movie recording on\n");
|
printf("movie recording on\n");
|
||||||
|
Reference in New Issue
Block a user