Bug#674060: Doesn't support reading InRelease files
tags 674060 + patch
thanks
On 22/05/12 21:36, Mehdi Dogguy wrote:
It seems that src/release.c:di_release_read_file can't read
InRelease files (yet) because it is not strictly an rfc822 file.
Please find attached a tentative patch to add support for InRelease
files to libd-i. It makes src/parser_rfc822.c:di_parser_rfc822_read skip
PGP signature and headers.
Regards,
--
Mehdi Dogguy مهدي الدڤي
http://dogguy.org/
>From caeda32359b1f3cbff3da9777d646f92f8c6b479 Mon Sep 17 00:00:00 2001
From: Mehdi Dogguy <mehdi@debian.org>
Date: Wed, 23 May 2012 13:18:59 +0200
Subject: [PATCH] Add support for InRelease files (Closes: #674060)
---
src/parser_rfc822.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/parser_rfc822.c b/src/parser_rfc822.c
index 67aa412..7049223 100644
--- a/src/parser_rfc822.c
+++ b/src/parser_rfc822.c
@@ -60,6 +60,7 @@ int di_parser_rfc822_read (char *begin, size_t size, di_parser_info *info, di_pa
di_rstring field_modifier_string;
di_rstring value_string;
void *act = NULL;
+ int pgp_mode = 0;
cur = begin;
end = begin + size;
@@ -81,6 +82,19 @@ int di_parser_rfc822_read (char *begin, size_t size, di_parser_info *info, di_pa
while (1)
{
+ if (!strncmp(cur, "-----BEGIN PGP SIGNED MESSAGE-----", 34))
+ {
+ // Enable pgp_mode
+ pgp_mode = 1;
+ // Let's skip this line
+ cur += 35;
+ }
+ else if (!strncmp(cur, "-----BEGIN PGP SIGNATURE-----", 29))
+ {
+ // Let's exit, the rest of the file is not interesting
+ cur += size;
+ break;
+ }
field_begin = cur;
readsize = end - field_begin < READSIZE ? end - field_begin : READSIZE;
if (!readsize)
@@ -145,6 +159,14 @@ int di_parser_rfc822_read (char *begin, size_t size, di_parser_info *info, di_pa
}
value_size = value_end - value_begin;
+ if (pgp_mode == 1 && !strncmp(field_begin, "Hash", field_size)) {
+ // Do not skip more "Hash" fields
+ pgp_mode++;
+ // Skip this entry (4 == ':' + ' ' + '\n' + '\n')
+ cur += field_size + value_size + 4;
+ continue;
+ }
+
field_string.string = field_begin;
field_string.size = field_size;
value_string.string = value_begin;
--
1.7.10
Reply to: