|
|
37efa4 |
From 34c649b3601383cd11dbc76221747ec16fd68e1b Mon Sep 17 00:00:00 2001
|
|
|
37efa4 |
From: Werner Koch <wk@gnupg.org>
|
|
|
37efa4 |
Date: Tue, 14 Jun 2022 11:33:27 +0200
|
|
|
37efa4 |
Subject: [PATCH GnuPG] g10: Fix garbled status messages in NOTATION_DATA
|
|
|
37efa4 |
|
|
|
37efa4 |
* g10/cpr.c (write_status_text_and_buffer): Fix off-by-one
|
|
|
37efa4 |
--
|
|
|
37efa4 |
|
|
|
37efa4 |
Depending on the escaping and line wrapping the computed remaining
|
|
|
37efa4 |
buffer length could be wrong. Fixed by always using a break to
|
|
|
37efa4 |
terminate the escape detection loop. Might have happened for all
|
|
|
37efa4 |
status lines which may wrap.
|
|
|
37efa4 |
|
|
|
37efa4 |
GnuPG-bug-id: T6027
|
|
|
37efa4 |
---
|
|
|
37efa4 |
g10/cpr.c | 13 ++++---------
|
|
|
37efa4 |
1 file changed, 4 insertions(+), 9 deletions(-)
|
|
|
37efa4 |
|
|
|
37efa4 |
diff --git a/g10/cpr.c b/g10/cpr.c
|
|
|
37efa4 |
index 9bfdd3c34..fa8005d6f 100644
|
|
|
37efa4 |
--- a/g10/cpr.c
|
|
|
37efa4 |
+++ b/g10/cpr.c
|
|
|
37efa4 |
@@ -372,20 +372,15 @@ write_status_text_and_buffer (int no, const char *string,
|
|
|
37efa4 |
}
|
|
|
37efa4 |
first = 0;
|
|
|
37efa4 |
}
|
|
|
37efa4 |
- for (esc=0, s=buffer, n=len; n && !esc; s++, n--)
|
|
|
37efa4 |
+ for (esc=0, s=buffer, n=len; n; s++, n--)
|
|
|
37efa4 |
{
|
|
|
37efa4 |
if (*s == '%' || *(const byte*)s <= lower_limit
|
|
|
37efa4 |
|| *(const byte*)s == 127 )
|
|
|
37efa4 |
esc = 1;
|
|
|
37efa4 |
if (wrap && ++count > wrap)
|
|
|
37efa4 |
- {
|
|
|
37efa4 |
- dowrap=1;
|
|
|
37efa4 |
- break;
|
|
|
37efa4 |
- }
|
|
|
37efa4 |
- }
|
|
|
37efa4 |
- if (esc)
|
|
|
37efa4 |
- {
|
|
|
37efa4 |
- s--; n++;
|
|
|
37efa4 |
+ dowrap=1;
|
|
|
37efa4 |
+ if (esc || dowrap)
|
|
|
37efa4 |
+ break;
|
|
|
37efa4 |
}
|
|
|
37efa4 |
if (s != buffer)
|
|
|
37efa4 |
es_fwrite (buffer, s-buffer, 1, statusfp);
|
|
|
37efa4 |
--
|
|
|
37efa4 |
2.37.1
|
|
|
37efa4 |
|