[PATCH v5 2/5] commit.c/GPG signature verification: Also look at the first GPG status line

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

 



Signed-off-by: Sebastian Götte <jaseg@xxxxxxxxxxxxxxxxxxxxxxxx>
---
 commit.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/commit.c b/commit.c
index e94d122..48f09e9 100644
--- a/commit.c
+++ b/commit.c
@@ -1027,27 +1027,33 @@ static struct {
 	char result;
 	const char *check;
 } sigcheck_gpg_status[] = {
-	{ 'G', "\n[GNUPG:] GOODSIG " },
-	{ 'B', "\n[GNUPG:] BADSIG " },
+	{ 'G', "[GNUPG:] GOODSIG " },
+	{ 'B', "[GNUPG:] BADSIG " },
 };
 
 static void parse_gpg_output(struct signature_check *sigc)
 {
-	const char *buf = sigc->gpg_status;
 	int i;
 
+	/* Iterate over all search strings */
 	for (i = 0; i < ARRAY_SIZE(sigcheck_gpg_status); i++) {
-		const char *found = strstr(buf, sigcheck_gpg_status[i].check);
-		const char *next;
-		if (!found)
-			continue;
-		sigc->check_result = sigcheck_gpg_status[i].result;
-		found += strlen(sigcheck_gpg_status[i].check);
-		sigc->key = xmemdupz(found, 16);
-		found += 17;
-		next = strchrnul(found, '\n');
-		sigc->signer = xmemdupz(found, next - found);
-		break;
+		const char *found = sigc->gpg_status;
+
+		/* Iterate over all lines */
+		do {
+			if (!prefixcmp(found, sigcheck_gpg_status[i].check)) {
+				const char *next;
+				
+				found += strlen(sigcheck_gpg_status[i].check);
+				sigc->check_result = sigcheck_gpg_status[i].result;
+				sigc->key = xmemdupz(found, 16);
+				found += 17;
+				next = strchrnul(found, '\n');
+				sigc->signer = xmemdupz(found, next - found);
+				return;
+			}
+			found = strchr(found, '\n')+1;
+		} while(found-1);
 	}
 }
 
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]