From 5f2b7136caa0fe12a3d8acd933fde40c49d80dcd Mon Sep 17 00:00:00 2001 From: Andrey Skvortsov Date: Thu, 29 May 2025 00:10:50 +0300 Subject: [PATCH] main: replace sprintf with safer snprintf --- src/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 90fe1f6..75fd301 100644 --- a/src/main.c +++ b/src/main.c @@ -318,7 +318,7 @@ struct capture_completed_args { static bool capture_completed(struct capture_completed_args *args) { - strncpy(last_path, args->fname, 259); + snprintf(last_path, sizeof(last_path), args->fname); gtk_image_set_from_paintable(GTK_IMAGE(thumb_last), GDK_PAINTABLE(args->thumb)); @@ -618,7 +618,7 @@ run_open_last_action(GSimpleAction *action, GVariant *param, gpointer user_data) if (strlen(last_path) == 0) { return; } - sprintf(uri, "file://%s", last_path); + snprintf(uri, sizeof(uri), "file://%s", last_path); if (!g_app_info_launch_default_for_uri(uri, NULL, &error)) { g_printerr("Could not launch image viewer for '%s': %s\n", uri, @@ -631,7 +631,7 @@ run_open_photos_action(GSimpleAction *action, GVariant *param, gpointer user_dat { char uri[270]; g_autoptr(GError) error = NULL; - sprintf(uri, "file://%s", g_get_user_special_dir(G_USER_DIRECTORY_PICTURES)); + snprintf(uri, sizeof(uri), "file://%s", g_get_user_special_dir(G_USER_DIRECTORY_PICTURES)); if (!g_app_info_launch_default_for_uri(uri, NULL, &error)) { g_printerr("Could not launch image viewer: %s\n", error->message); }