$OpenBSD: patch-gputils_dump_c,v 1.3 2004/01/30 01:01:11 naddy Exp $ --- gputils/dump.c.orig 2004-01-02 10:29:37.000000000 +1100 +++ gputils/dump.c 2004-01-25 20:46:55.000000000 +1100 @@ -28,10 +28,12 @@ Boston, MA 02111-1307, USA. */ int number_of_source_files = 0; -char *substr(char *a, char *b, int n) +char *substr(char *a, size_t sizeof_a, char *b, size_t n) { - *a = 0; - return strncat(a,b,n); + strlcpy(a, b, sizeof_a); + if (n < sizeof_a) + a[n] = 0; + return a; } @@ -283,7 +285,7 @@ void dump_symbols( void ) if(temp[i*SSYMBOL_SIZE + SR_NAME]) printf("%s = %x, type = %s\n", - substr(b,&temp[i*SSYMBOL_SIZE + SR_NAME],12), + substr(b, sizeof(b), &temp[i*SSYMBOL_SIZE + SR_NAME],12), gp_getu16(&temp[i*SSYMBOL_SIZE + SR_VALUE]), SymbolType4[(unsigned char)temp[i*SSYMBOL_SIZE + SR_TYPE]] ); @@ -335,7 +337,7 @@ void dump_lsymbols( void ) value = gp_getb32(&s[length+3]); printf("%s = %x, type = %s\n", - substr(b,&s[1],length), + substr(b, sizeof(b), &s[1],length), value, SymbolType4[type]); i += (length + 7); @@ -375,12 +377,14 @@ void dump_source_files( void ) for(i=0; i