From fa547401997c3fecb1ef500d3b496ceeb413a0e2 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 4 Oct 2011 01:08:27 +0200 Subject: [PATCH] Fix format string vulnerability by using g_set_error_literal () --- plugins/am-project/am-project.c | 18 ++++++++++++++---- plugins/mk-project/mk-project.c | 15 ++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c index ca3f6b0ae..05c6d8fec 100644 --- a/plugins/am-project/am-project.c +++ b/plugins/am-project/am-project.c @@ -1651,11 +1651,21 @@ amp_project_load_root (AmpProject *project, GError **error) if (project->configure_token == NULL) { - g_set_error (error, IANJUTA_PROJECT_ERROR, + if (err != NULL) + { + g_set_error_literal (error, IANJUTA_PROJECT_ERROR, + IANJUTA_PROJECT_ERROR_PROJECT_MALFORMED, + err->message); + g_error_free (err); + } + else + { + g_set_error (error, IANJUTA_PROJECT_ERROR, IANJUTA_PROJECT_ERROR_PROJECT_MALFORMED, - err == NULL ? _("Unable to parse project file") : err->message); - if (err != NULL) g_error_free (err); - return FALSE; + _("Unable to parse project file")); + } + + return FALSE; } /* Load all makefiles recursively */ diff --git a/plugins/mk-project/mk-project.c b/plugins/mk-project/mk-project.c index 65dc5d776..27a09cf3d 100644 --- a/plugins/mk-project/mk-project.c +++ b/plugins/mk-project/mk-project.c @@ -486,10 +486,19 @@ project_load_makefile (MkpProject *project, GFile *file, MkpGroup *parent, GErro mkp_scanner_free (scanner); if (!ok) { - g_set_error (error, IANJUTA_PROJECT_ERROR, + if (err != NULL) + { + g_set_error_literal (error, IANJUTA_PROJECT_ERROR, IANJUTA_PROJECT_ERROR_PROJECT_MALFORMED, - err == NULL ? _("Unable to parse make file") : err->message); - if (err != NULL) g_error_free (err); + err->message); + g_error_free (err); + } + else + { + g_set_error (error, IANJUTA_PROJECT_ERROR, + IANJUTA_PROJECT_ERROR_PROJECT_MALFORMED, + _("Unable to parse make file")); + } return NULL; } -- 2.11.4.GIT