[gcr] egg-armor: Handle mismatched but not truncated suffix line



commit 61de15c7c7fe50d075ee77b2c9c4ce7c6284ce12
Author: Stef Walter <stefw gnome org>
Date:   Fri Jan 11 21:48:23 2013 +0100

    egg-armor: Handle mismatched but not truncated suffix line
    
     * Discovered by Gustavo Luiz Duarte <gustavold linux vnet ibm com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691505

 egg/egg-armor.c        |    2 +-
 egg/tests/test-armor.c |    5 +++++
 2 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/egg/egg-armor.c b/egg/egg-armor.c
index dd213d0..02e7646 100644
--- a/egg/egg-armor.c
+++ b/egg/egg-armor.c
@@ -173,7 +173,7 @@ armor_find_end (const gchar *data,
 	at += n_type;
 
 	/* Next comes the suffix */
-	if (ARMOR_SUFF_L > len && strncmp ((gchar*)at, ARMOR_SUFF, ARMOR_SUFF_L) != 0)
+	if (ARMOR_SUFF_L > len || strncmp ((gchar *)at, ARMOR_SUFF, ARMOR_SUFF_L) != 0)
 		return NULL;
 
 	/*
diff --git a/egg/tests/test-armor.c b/egg/tests/test-armor.c
index d5a366b..7435a10 100644
--- a/egg/tests/test-armor.c
+++ b/egg/tests/test-armor.c
@@ -148,6 +148,11 @@ main (int argc, char **argv)
 	g_test_add_data_func ("/armor/invalid-suffix",
 	                      "-----BEGIN TEST-----\n"
 	                      "Z29vZCBtb3JuaW5nIGV2ZXJ5b25lCg==\n"
+	                      "-----END TEST--xxxxxxxx\n",
+	                      test_invalid);
+	g_test_add_data_func ("/armor/invalid-truncated",
+	                      "-----BEGIN TEST-----\n"
+	                      "Z29vZCBtb3JuaW5nIGV2ZXJ5b25lCg==\n"
 	                      "-----END TEST--\n",
 	                      test_invalid);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]