From acfbb13661f425631ee7e7f01daa1eb2f3169945 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 28 Nov 2018 12:27:14 -0800 Subject: macOS: replace local strnstr with strcasestr. bionic, glibc, macOS, and musl all have strcasestr (see http://man7.org/linux/man-pages/man3/strstr.3.html). macOS (via BSD) has a strnstr that does what strnstr sounds like it should do by analogy with strnlen and strncpy. So we at least need to rename strnstr, but it probably makes more sense just to switch to strcasestr instead. --- toys/lsb/passwd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toys/lsb') diff --git a/toys/lsb/passwd.c b/toys/lsb/passwd.c index 0f51c0c0..73024832 100644 --- a/toys/lsb/passwd.c +++ b/toys/lsb/passwd.c @@ -46,8 +46,8 @@ static void weak_check(char *new, char *old, char *user) if (strlen(new) < 6) msg = "too short"; if (*new) { - if (strnstr(new, user) || strnstr(user, new)) msg = "user"; - if (*old && (strnstr(new, old) || strnstr(old, new))) msg = "old"; + if (strcasestr(new, user) || strcasestr(user, new)) msg = "user"; + if (*old && (strcasestr(new, old) || strcasestr(old, new))) msg = "old"; } if (msg) xprintf("BAD PASSWORD: %s\n",msg); } -- cgit v1.2.3