-
Here is another patch with hopefully a bit less fail in it. :-)
This adds a new API call, TextUtils::copy(), which is currently a wrapper around strncpy() that guarantees that the result is null terminated. As brlcad suggested, using strlcpy() if it is available would be an improvement to this.
I also converted a number of places to use the new strncpy() wrapper. In most cases, the code...
2009-11-15 00:15:13 UTC by russellbryant
-
strlcpy is the secured version that null-terminates the result, but isn't available on all platforms. A patch that provides a wrapper around strlcpy (using a null-terminating strncpy if it doesn't exist) would be useful to have.
2009-11-12 20:09:35 UTC by brlcad
-
I assumed that data is always a valid string (because it was being tacked on to a std::string, theData).
If the data is not a string, then "theData += p" could produce some odd results with the existing code. If it's just opaque data, then it could have embedded nulls in it, causing not all of the data to make it into theData.
2009-11-12 14:46:35 UTC by russellbryant
-
I made a poor assumption that strncpy() guarantees the null terminator. Oops. I'll rework this.
In another project, we had replaced the usage of strncpy() with a custom function with more sane behavior, causing me to forget the details of the standard function. :-)
2009-11-12 14:40:27 UTC by russellbryant
-
[Join Game -> Start Server -> Server Reset]
This setting is not saved. As a result, it always reverts back to "no, quit after game". When we're playing among friends we want it to say "yes" so that we can at least see our scores after a match timeout elapses instead of being kicked off with no idea of who had what score.
2009-11-12 12:45:57 UTC by lhunath
-
This patch improves the efficiency of the BZFSNetLogCB class.
Specifically, the network log callback was doing a malloc() and free() every time it needed to send out a network event through the worldEventManager. Instead of continuously calling malloc()/free(), this patch caches the allocation for reuse and increases its size as necessary.
2009-11-12 03:17:02 UTC by russellbryant
-
This patch removes a FIXME from src/bzfs/bzfs.cxx by moving some code to remove the need to forward declare a couple of functions.
2009-11-12 00:26:56 UTC by russellbryant
-
This small patch addresses a memory leak in some curses wrappers. I'm not sure what the main intended purposes of these wrappers are. It looks like they are just to deal with cases where waddstr() is not defined to take a const char * argument. So, this patch just casts away the const qualifier. (I sure hope no implementation of waddstr() would actually modify the string, that would be...
2009-11-11 14:52:41 UTC by russellbryant
-
As the 3rd parameter at the strncpy is the length of the buffer, passing sizeof(buffer) -1 as this parameter you could eventually not copy the null terminator if the strlen of the source string is equal to sizeof(buffer) -1
That was why all those memset to 0 or dest[len]='\0' was there.
2009-11-11 07:46:36 UTC by atupone
-
This patch cleans up some code related to the use of strncpy() across the tree. The most "important" change is to fix a number of off by one errors. By passing the exact buffer size as the third argument, it is possible for strncpy() to write one byte past the end of the buffer.
While reviewing uses of strncpy() for this problem, some related cleanup was done:
1) Instead of using hard...
2009-11-11 04:18:15 UTC by russellbryant