tests: avoid write-beyond-end-of-heap buffer
authorJim Meyering <jim@meyering.net>
Fri, 11 Nov 2011 10:38:19 +0000 (11:38 +0100)
committerWerner Koch <wk@gnupg.org>
Fri, 11 Nov 2011 15:03:26 +0000 (16:03 +0100)
commit377ff84d2187e02e723068d2b14a25cdbc7f5755
treede90f377f57fee7f6aa76daecec1e1bda1bd61ed
parentba7127721035ee0937167e16465cc9f40b39257d
tests: avoid write-beyond-end-of-heap buffer

In libgcrypt's "make check" (latest from git), I was surprised to
see the "basic" test fail.  Here's a patch:

Avoid scary-looking (with MALLOC_CHECK_=3) "make check" test failure:

  *** glibc detected *** /h/j/w/co/libgcrypt/tests/.libs/lt-basic: free(): invalid
  pointer: 0x0000000001f9d080 ***
  ======= Backtrace: =========
  /lib64/libc.so.6[0x3a5807c606]
  /w/libgcrypt/src/.libs/libgcrypt.so.19(+0x100c9)[0x7f890edb90c9]
  /w/libgcrypt/src/.libs/libgcrypt.so.19(+0xb03e)[0x7f890edb403e]
  /w/libgcrypt/src/.libs/libgcrypt.so.19(gcry_free+0x18)[0x7f890edb1eef]
  /w/libgcrypt/tests/.libs/lt-basic[0x4091f4]
  /w/libgcrypt/tests/.libs/lt-basic[0x40b541]
  /lib64/libc.so.6(__libc_start_main+0xed)[0x3a5802169d]
  /w/libgcrypt/tests/.libs/lt-basic[0x401979]
  ======= Memory map: ========
  00400000-00411000 r-xp 00000000 08:08 2787510 /w/co/libgcrypt/tests/.libs/lt-basic
  ...

>From 722e6d470371bb3d995e0a6a67cd9c2ffd7bb664 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Fri, 11 Nov 2011 11:34:45 +0100
Subject: [PATCH] tests: avoid write-beyond-end-of-heap buffer

* basic.c (check_bulk_cipher_modes): Allocate one more byte in
each of the two test buffers.  Otherwise, running
"env -i MALLOC_CHECK_=3 ./basic" would abort.
tests/ChangeLog
tests/basic.c