siliconsam / imp2022

IMP77 compiler for Linux
1 stars 0 forks source link

Bug: string overflow #1

Closed gtoal closed 1 year ago

gtoal commented 1 year ago
pass3.h:#define SYMNMLEN    8
pass3.h:    char            s_name[SYMNMLEN];   // section name
pass3coff.c:    strcpy(directhead.s_name, ".drectve");
pass3coff.c:        strcpy(traphead.s_name, "_ITRAP$B");
pass3coff.c:        strcpy(traphead.s_name, "_ITRAP$D");
pass3coff.c:    strcpy(trapendhead.s_name, "_ITRAP$F");

GCC actually warns about this:

In file included from /usr/include/string.h:494:0,
                 from pass3coff.c:12:
In function ‘strcpy’,
    inlined from ‘initcoff’ at pass3coff.c:842:5:
/usr/include/i386-linux-gnu/bits/string_fortified.h:90:10: warning: ‘__builtin___strcpy_chk’ writing 9 bytes into a region of size 8 overflows the destination [-Wstring
op-overflow=]
   return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and many others.

siliconsam commented 1 year ago

Fixed in my temporary experimental WSL (Ubuntu) environment. Bug fix should be available in next release. Currently fixing problems with IMP signal handling in a Linux environment.