Euphoria
Ticket #510:
remove use of strcpy in be_w.c, 631
-
Reported by
jeremy
Dec 06, 2010
The comment says its safe but that doesn't ensure its safety. Lint checkers, other code analysis tools and even some linkers such as OpenBSD complain about the use of strcpy.
Details
1. Comment by jimcbrown
Dec 06, 2010
It also complains about sprintf().
2. Comment by jeremy
Dec 06, 2010
We should fix that as well. We should really be as safe w/the code as possible. Already on the ticket list is a scan by Coverity. We are no where near that type of quality right now but we should be striving for it.
3. Comment by jeremy
Dec 06, 2010
Is there a down side to updating it?
4. Comment by jimcbrown
Dec 06, 2010
I fixed up strcpy, strcat, and sprintf. Ideally, we should be adding a '\0' manually after each of these calls (like chararray[LENGTH-1] = '\0') to make sure that the strings are null terminated. (I didn't bother to do this because we know that these lengths are safe.)
5. Comment by DerekParnell
Dec 06, 2010
Is the code in be_machine.c correct ...
strncat(dest, "=", 2);
We are only concatenating one character, no?
6. Comment by DerekParnell
Dec 06, 2010
The string copy functions that we wrote for Euphoria use two lengths; the size of the receiving area and the count of characters to copy. They make sure that we don't overrun the receiving buffer area.
7. Comment by jimcbrown
Dec 07, 2010
I'll change the strncpy() to copy_string() and strncat() to append_string().
Not sure what to use to replace snprintf()
8. Comment by mattlewis
Dec 07, 2010
I thought snprintf() was the safe replacement for sprintf().
9. Comment by jimcbrown
Dec 07, 2010
This is fixed.