We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3947 - replace strlcpy with memcpy in SDL_strdup()
Summary: replace strlcpy with memcpy in SDL_strdup()
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: All All
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-06 19:38 UTC by Ozkan Sezer
Modified: 2018-02-13 16:13 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ozkan Sezer 2017-11-06 19:38:25 UTC
The following patch replaces SDL_strlcpy() with SDL_memcpy()
in SDL_strdup(), which should be more efficient.

diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c
--- a/src/stdlib/SDL_string.c
+++ b/src/stdlib/SDL_string.c
@@ -564,7 +564,7 @@ SDL_strdup(const char *string)
     size_t len = SDL_strlen(string) + 1;
     char *newstr = SDL_malloc(len);
     if (newstr) {
-        SDL_strlcpy(newstr, string, len);
+        SDL_memcpy(newstr, string, len);
     }
     return newstr;
 }
Comment 1 Sam Lantinga 2018-02-13 16:13:55 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/68864895c386