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

Bug#674060: Doesn't support reading InRelease files



On Fri, May 25, 2012 at 11:01:57AM +0200, Mehdi Dogguy wrote:
> index 67aa412..0b0f802 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,25 @@ 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))

Please don't use magic numbers.
| const char pgp_begin = "…";
| if (!strncmp(cur, pgp_begin, strlen(pgp_begin))
or something like that. The strlen call should be optimized away.

Also this string may only appear at the beginning of the file, not
somewhere in between. So this should be done before the large loop.
Also the end of the preamble can be searched with \n\n.

> +      else if (pgp_mode && !strncmp(cur, "-----BEGIN PGP SIGNATURE-----", 29))
> +      {
> +        // Let's exit, the rest of the file is not interesting
> +        cur += size;
> +        break;
> +      }

Okay.

Bastian

-- 
The best diplomat I know is a fully activated phaser bank.
		-- Scotty



Reply to: