Commit Graph

12 Commits

Author SHA1 Message Date
Peter Jones f725fa7cb2 calloc: Use calloc() at most places
This modifies most of the places we do some form of:

  X = malloc(Y * Z);

to use calloc(Y, Z) instead.

Among other issues, this fixes:
  - allocation of integer overflow in grub_png_decode_image_header()
    reported by Chris Coulson,
  - allocation of integer overflow in luks_recover_key()
    reported by Chris Coulson,
  - allocation of integer overflow in grub_lvm_detect()
    reported by Chris Coulson.

Fixes: CVE-2020-14308

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-07-29 16:55:47 +02:00
Colin Watson e5ba6b2618 libgcrypt: Import replacement CRC operations
The CRC implementation imported from libgcrypt 1.5.3 is arguably
non-free, due to being encumbered by the restrictive Internet Society
licence on RFCs (see e.g. https://wiki.debian.org/NonFreeIETFDocuments).
Fortunately, libgcrypt has since replaced it with a version that is both
reportedly better-optimised and doesn't suffer from this encumbrance.

The ideal solution would be to update to a new version of libgcrypt, and
I spent some time trying to do that.  However, util/import_gcry.py
requires complex modifications to cope with the new version, and I
stalled part-way through; furthermore, GRUB's libgcrypt tree already
contains some backports of upstream changes.  Rather than allowing the
perfect to be the enemy of the good, I think it's best to backport this
single change to at least sort out the licensing situation.  Doing so
won't make things any harder for a future wholesale upgrade.

This commit is mostly a straightforward backport of
https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commitdiff;h=06e122baa3321483a47bbf82fd2a4540becfa0c9,
but I also imported bufhelp.h from libgcrypt 1.7.0 (newer versions
required further changes elsewhere).

I've tested that "hashsum -h crc32" still produces correct output for a
variety of files on both i386-pc and x86_64-emu targets.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-02-23 22:37:36 +01:00
Vladimir Serbinenko 4127206896 Make rijndael.c respect aliasing rules.
Trivial backport of dfb4673da8ee52d95e0a62c9f49ca8599943f22e.
2013-12-24 16:57:28 +01:00
Vladimir Serbinenko 35de6d4bac * grub-core/lib/libgcrypt/mpi/longlong.h: Fix compilation error with
-march=armv3.
2013-11-30 11:19:06 +01:00
Vladimir Serbinenko a92b5cb8d8 * grub-core/lib/libgcrypt/mpi/longlong.h: Use C version with mips
clang.
2013-11-23 00:36:13 +01:00
Vladimir Serbinenko 2dc1eb6cbf * grub-core/lib/libgcrypt/cipher/idea.c (mul_inv): Remove signed
divisions.
2013-11-08 18:10:07 +01:00
Vladimir Serbinenko b9563c9451 * grub-core/lib/libgcrypt/mpi/mpih-div.c (_gcry_mpih_divrem):
Use grub_fatal rather than divide by zero.
	* grub-core/lib/libgcrypt/mpi/mpi-pow.c (gcry_mpi_powm): Likewise.
2013-11-08 16:33:48 +01:00
Vladimir Serbinenko d1307d873a Import libgcrypt 1.5.3. 2013-11-07 06:35:50 +01:00
Vladimir 'phcoder' Serbinenko 5e3b8dcbb5 Import gcrypt public-key cryptography and implement signature checking. 2013-01-11 21:32:42 +01:00
Vladimir 'phcoder' Serbinenko e5f4d2607a * grub-core/lib/libgcrypt/cipher/md4.c (transform) [WORDS_BIGENDIAN]:
Add missing const attribute.
	* grub-core/lib/libgcrypt/cipher/md5.c (transform) [WORDS_BIGENDIAN]:
	Likewise.
	* grub-core/lib/libgcrypt/cipher/rmd160.c (transform) [WORDS_BIGENDIAN]:
	Likewise.
2011-12-15 20:26:17 +01:00
Vladimir 'phcoder' Serbinenko 8e54b4b76a * grub-core/lib/libgcrypt/cipher/serpent.c (serpent_key_prepare): Fix
misaligned access.
	(serpent_setkey): Likewise.
	(serpent_encrypt_internal): Likewise.
	(serpent_decrypt_internal): Likewise.
	(serpent_encrypt): Don't put an alignment-increasing cast.
	(serpent_decrypt): Likewise.
	(serpent_test): Likewise.
2011-12-15 20:20:02 +01:00
BVK Chaitanya 8c41176882 automake commit without merge history 2010-05-06 11:34:04 +05:30