From: Ben Pfaff Date: Fri, 29 Oct 2004 04:29:29 +0000 (+0000) Subject: Fix bug in strlcpy() that could cause reading too much data from the X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d6e7520acd99ae0e231d3cfce5e72402e1cdf72;hp=7383847de838eb2026001416ba11fa99c85d556c;p=pintos-anon Fix bug in strlcpy() that could cause reading too much data from the source string. Thanks to Jim Chow for reporting the bug and providing the fix. --- diff --git a/src/lib/string.c b/src/lib/string.c index 8971fae..89fa1f0 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -339,7 +339,7 @@ strlcpy (char *dst, const char *src, size_t size) { size_t dst_len = size - 1; if (src_len < dst_len) - src_len = dst_len; + dst_len = src_len; memcpy (dst, src, dst_len); dst[dst_len] = '\0'; }