[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Question about memory under MagiC



Op 10/22/11 11:45 PM, Jean-François Lemaire schreef:

char path[PATHSIZE] = {0};
size_t size = snprintf(path, sizeof path, "%s%s", string1, string2) + 1;

If string1 + string2 exceeds sizeof path, the terminating \0 might not
have been appended (happens also with strncpy).
Then the strcpy can copy too many characters.

--
Groeten; Regards.
Henk Robbers. http://members.chello.nl/h.robbers
Interactive disassembler: TT-Digger;  http://digger.atari.org
A Home Cooked C compiler:      AHCC;  http://ahcc.atari.org