pkgsrc/devel/gputils/patches/patch-libgputils_gparchive.c
bouyer ce3308b37b update gputils to 1.5.0. Changes since 1.4.2:
Several pre-defined constant and variable in the gpasm.
    Extension of error and messg directives: These directives - inside of the parameter string - recognize and execute the #v() macro.
    New directives: __badrom, assume, elif, elifdef, elifndef
    New gplink feature: Remove the unnecessary banksel and pagesel directives.
    The errorlevel directive accept number ranges. E.g. +303-310 or -303-310
    The gpvo utility use the disassembler to decode the program memory sections.
    The gplink save the local RAM symbols to COD file.
    The ".direct" directive - inside of the parameter string - recognize and execute the #v() macro.
    The length of source file names in COD file, now 256 bytes long instead of 64 bytes. The gpvc utility thereafter also able to correctly detect the shorter names.
    The inc and lkr files are synced with MPLABX 3.35
2018-06-25 14:01:45 +00:00

27 lines
1.1 KiB
C

$NetBSD: patch-libgputils_gparchive.c,v 1.2 2018/06/25 14:01:45 bouyer Exp $
Be more paranoid about input, pursuant to a build failure in sdcc3
that seems to involve gplib trying to allocate gigs of memory.
--- libgputils/gparchive.c.orig 2016-08-12 15:14:27.000000000 +0200
+++ libgputils/gparchive.c 2018-06-25 14:40:35.697419998 +0200
@@ -378,10 +378,18 @@
/* read the object file or symbol index into memory */
sscanf(new->header.ar_size, "%il", &object_size);
+ if (object_size < 0) {
+ gp_error("bad archive \"%s\" (negative entry size)", File_name);
+ }
+ /* sanity check */
+ if (object_size > 100*1024*1024) {
+ gp_error("bad archive \"%s\" (unreasonable entry size %d)", File_name,
+ object_size);
+ }
new->data.size = object_size;
new->data.file = (uint8_t *)GP_Malloc(object_size);
if (fread(new->data.file, sizeof(char), object_size, infile) != object_size) {
- gp_error("bad archive \"%s\"", File_name);
+ gp_error("bad archive \"%s\" (read error)", File_name);
}
/* insert the new member in the archive list */