grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 3/6] bootstrap: Add gnulib's base64 module


From: Max Tottenham
Subject: Re: [PATCH 3/6] bootstrap: Add gnulib's base64 module
Date: Mon, 4 Nov 2019 10:30:01 +0000
User-agent: Mutt/1.9.4 (2018-02-28)

On 11/02, Patrick Steinhardt wrote:
> The upcoming support for LUKS2 disc encryption requires us to include a
> parser for base64-encoded data, as it is used to represent salts and
> digests. As gnulib already has code to decode such data, we can just
> add it to the boostrapping configuration in order to make it available
> in GRUB.
> 
> The gnulib module makes use of booleans via the <stdbool.h> header. As
> GRUB does not provide any POSIX wrapper header for this, but instead
> implements support for `bool` in <sys/types.h>, we need to patch
> base64.h to not use <stdbool.h> anymore. We unfortunately cannot include
> <sys/types.h> instead, as it would then use gnulib's internal header
> while compiling the gnulib object but our own <sys/types.h> when
> including it in a GRUB module. Because of this, the patch replaces the
> include with a direct typedef.
> 
> Signed-off-by: Patrick Steinhardt <address@hidden>
> ---
>  bootstrap.conf                                |  3 ++-
>  conf/Makefile.extra-dist                      |  1 +
>  grub-core/lib/gnulib-patches/fix-base64.patch | 26 +++++++++++++++++++
>  3 files changed, 29 insertions(+), 1 deletion(-)
>  create mode 100644 grub-core/lib/gnulib-patches/fix-base64.patch
> 
> diff --git a/bootstrap.conf b/bootstrap.conf
> index 988dda099..22b908f36 100644
> --- a/bootstrap.conf
> +++ b/bootstrap.conf
> @@ -23,6 +23,7 @@ GNULIB_REVISION=d271f868a8df9bbec29049d01e056481b7a1a263
>  # directly.
>  gnulib_modules="
>    argp
> +  base64
>    error
>    fnmatch
>    getdelim
> @@ -78,7 +79,7 @@ cp -a INSTALL INSTALL.grub
>  
>  bootstrap_post_import_hook () {
>    set -e
> -  for patchname in fix-null-deref fix-width no-abort; do
> +  for patchname in fix-base64 fix-null-deref fix-width no-abort; do
>      patch -d grub-core/lib/gnulib -p2 \
>        < "grub-core/lib/gnulib-patches/$patchname.patch"
>    done
> diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
> index 46c4e95e2..32b217853 100644
> --- a/conf/Makefile.extra-dist
> +++ b/conf/Makefile.extra-dist
> @@ -28,6 +28,7 @@ EXTRA_DIST += grub-core/gensymlist.sh
>  EXTRA_DIST += grub-core/genemuinit.sh
>  EXTRA_DIST += grub-core/genemuinitheader.sh
>  
> +EXTRA_DIST += grub-core/lib/gnulib-patches/fix-base64.patch
>  EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch
>  EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch
>  EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch
> diff --git a/grub-core/lib/gnulib-patches/fix-base64.patch 
> b/grub-core/lib/gnulib-patches/fix-base64.patch
> new file mode 100644
> index 000000000..392f21fb1
> --- /dev/null
> +++ b/grub-core/lib/gnulib-patches/fix-base64.patch
> @@ -0,0 +1,26 @@
> +diff --git a/lib/base64.h b/lib/base64.h
> +index 9cd0183b8..7b06e03df 100644
> +--- a/lib/base64.h
> ++++ b/lib/base64.h
> +@@ -21,8 +21,10 @@
> + /* Get size_t. */
> + # include <stddef.h>
> + 
> +-/* Get bool. */
> +-# include <stdbool.h>
> ++#ifndef GRUB_POSIX_BOOL_DEFINED
> ++typedef enum { false = 0, true = 1 } bool;
> ++#define GRUB_POSIX_BOOL_DEFINED 1
> ++#endif
> + 
> + # ifdef __cplusplus
> + extern "C" {
> +@@ -38,7 +40,7 @@ struct base64_decode_context
> +   char buf[4];
> + };
> + 
> +-extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST;
> ++extern bool isbase64 (char ch);

Is there a reason the const attribute has been removed from this
function in this patch? If so then I think you should add a rationale
for that in your commit message.

> + 
> + extern void base64_encode (const char *restrict in, size_t inlen,
> +                            char *restrict out, size_t outlen);
> -- 
> 2.23.0
> 
> 
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/grub-devel

-- 
Max Tottenham       | address@hidden
Senior Software Engineer, Server Platform Engineering
/(* Akamai Technologies



reply via email to

[Prev in Thread] Current Thread [Next in Thread]