aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-02-10 21:05:22 -0600
committerRob Landley <rob@landley.net>2016-02-10 21:05:22 -0600
commitf435f0412aa4ca631aa178d10ed33008e34f37cb (patch)
tree6174226167b101bda2ad4557b6e5b42987e64ad2 /lib/lib.c
parent3684510034450f5f50d1ad9b5acca327a5c484dd (diff)
downloadtoybox-f435f0412aa4ca631aa178d10ed33008e34f37cb.tar.gz
Factor out strnstr() since posix hasn't got it, and add a config option for
the deeply sad passwd heuristics that don't even check numbers and punctuation.
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 6559030c..681d4d23 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -1033,3 +1033,14 @@ char *next_printf(char *s, char **start)
return 0;
}
+
+// Posix inexplicably hasn't got this, so find str in line.
+char *strnstr(char *line, char *str)
+{
+ long len = strlen(str);
+ char *s;
+
+ for (s = line; *s; s++) if (!strncasecmp(s, str, len)) break;
+
+ return *s ? s : 0;
+}