+2021-11-12 Martin Liska <mliska@suse.cz>
+
+ PR libbacktrace/103167
+ * elf.c (elf_uncompress_lzma_block): Cast to unsigned int.
+ (elf_uncompress_lzma): Likewise.
+ * xztest.c (test_samples): memcpy only if v > 0.
+
+2021-10-22 Martin Liska <mliska@suse.cz>
+
+ PR testsuite/102742
+ * btest.c (MIN_DESCRIPTOR): New.
+ (MAX_DESCRIPTOR): Likewise.
+ (check_available_files): Likewise.
+ (check_open_files): Check only file descriptors that
+ were not available at the entry.
+ (main): Call check_available_files.
+
2021-08-13 Sergei Trofimovich <siarheit@google.com>
* install-debuginfo-for-buildid.sh.in: Force non-localized readelf
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/stat.h>
#include "filenames.h"
return failures;
}
+#define MIN_DESCRIPTOR 3
+#define MAX_DESCRIPTOR 10
+
+static int fstat_status[MAX_DESCRIPTOR];
+
+/* Check files that are available. */
+
+static void
+check_available_files (void)
+{
+ struct stat s;
+ for (unsigned i = MIN_DESCRIPTOR; i < MAX_DESCRIPTOR; i++)
+ fstat_status[i] = fstat (i, &s);
+}
+
/* Check that are no files left open. */
static void
check_open_files (void)
{
- int i;
-
- for (i = 3; i < 10; i++)
+ for (unsigned i = MIN_DESCRIPTOR; i < MAX_DESCRIPTOR; i++)
{
- if (close (i) == 0)
+ if (fstat_status[i] != 0 && close (i) == 0)
{
fprintf (stderr,
"ERROR: descriptor %d still open after tests complete\n",
int
main (int argc ATTRIBUTE_UNUSED, char **argv)
{
+ check_available_files ();
+
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
error_callback_create, NULL);
/* Block header CRC. */
computed_crc = elf_crc32 (0, compressed + block_header_offset,
block_header_size - 4);
- stream_crc = (compressed[off]
- | (compressed[off + 1] << 8)
- | (compressed[off + 2] << 16)
- | (compressed[off + 3] << 24));
+ stream_crc = ((uint32_t)compressed[off]
+ | ((uint32_t)compressed[off + 1] << 8)
+ | ((uint32_t)compressed[off + 2] << 16)
+ | ((uint32_t)compressed[off + 3] << 24));
if (unlikely (computed_crc != stream_crc))
{
elf_uncompress_failed ();
/* Next comes a CRC of the stream flags. */
computed_crc = elf_crc32 (0, compressed + 6, 2);
- stream_crc = (compressed[8]
- | (compressed[9] << 8)
- | (compressed[10] << 16)
- | (compressed[11] << 24));
+ stream_crc = ((uint32_t)compressed[8]
+ | ((uint32_t)compressed[9] << 8)
+ | ((uint32_t)compressed[10] << 16)
+ | ((uint32_t)compressed[11] << 24));
if (unlikely (computed_crc != stream_crc))
{
elf_uncompress_failed ();
/* Before that is a footer CRC. */
computed_crc = elf_crc32 (0, compressed + offset, 6);
- stream_crc = (compressed[offset - 4]
- | (compressed[offset - 3] << 8)
- | (compressed[offset - 2] << 16)
- | (compressed[offset - 1] << 24));
+ stream_crc = ((uint32_t)compressed[offset - 4]
+ | ((uint32_t)compressed[offset - 3] << 8)
+ | ((uint32_t)compressed[offset - 2] << 16)
+ | ((uint32_t)compressed[offset - 1] << 24));
if (unlikely (computed_crc != stream_crc))
{
elf_uncompress_failed ();
/* Next is a CRC of the index. */
computed_crc = elf_crc32 (0, compressed + index_offset,
offset - index_offset);
- stream_crc = (compressed[offset]
- | (compressed[offset + 1] << 8)
- | (compressed[offset + 2] << 16)
- | (compressed[offset + 3] << 24));
+ stream_crc = ((uint32_t)compressed[offset]
+ | ((uint32_t)compressed[offset + 1] << 8)
+ | ((uint32_t)compressed[offset + 2] << 16)
+ | ((uint32_t)compressed[offset + 3] << 24));
if (unlikely (computed_crc != stream_crc))
{
elf_uncompress_failed ();