X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flib%2Fstring.c;h=d223c89f48493793c52dc45dbcf288328776fd6f;hb=d4067a3abb1ef4537030835952e32f22f0063529;hp=8971fae21b3c4d6da492b2e54614dbb3e6f8e058;hpb=3b6db7448e41437dadc6b667929dea4a4f4013a6;p=pintos-anon diff --git a/src/lib/string.c b/src/lib/string.c index 8971fae..d223c89 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -1,8 +1,4 @@ #include - -#ifdef KERNEL -#define NDEBUG -#endif #include /* Copies SIZE bytes from SRC to DST, which must not overlap. @@ -194,7 +190,7 @@ strstr (const char *haystack, const char *needle) { size_t i; - for (i = 0; i < haystack_len - needle_len; i++) + for (i = 0; i <= haystack_len - needle_len; i++) if (!memcmp (haystack + i, needle, needle_len)) return (char *) haystack + i; } @@ -339,7 +335,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'; }