dsd/fprint_demo — Issue #1: Compilation of fprint_demo gives the warning: too many arguments for format [-Wformat-extra-args]
Author: malo-denielou
Created: 2012-01-30 11:57:12+00:00
State: open

This warning refers to missing or extra arguments for format string.
This can lead to vulnerabilities.
https://en.wikipedia.org/wiki/Format_string_vulnerabilities

Against the code from https://github.com/dsd/fprint_demo/tarball/v0.4
I attach a patch.
Hope it's useful.
Best,

Index: dsd-fprint_demo-f576f8c/src/identify.c
===================================================================
--- dsd-fprint_demo-f576f8c/src/identify.c
+++ dsd-fprint_demo-f576f8c/src/identify.c	2012-01-29 19:43:42.000000000 +0000
@@ -321,7 +321,7 @@
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
"Could not load print for %s, error %d",
-	fingerstr(i), r, NULL);
+	fingerstr(i), r);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);

Index: dsd-fprint_demo-f576f8c/src/verify.c
===================================================================
--- dsd-fprint_demo-f576f8c/src/verify.c
+++ dsd-fprint_demo-f576f8c/src/verify.c	2012-01-29 19:43:11.000000000 +0000
@@ -377,7 +377,7 @@
if (!gdk_pixbuf_save(pixbuf, filename, "png", &error, NULL)) {
dialog = gtk_message_dialog_new(GTK_WINDOW(mwin_window),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,
-	GTK_BUTTONS_CLOSE, error->message);
+	GTK_BUTTONS_CLOSE, "%s", error->message);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
g_error_free(error);