libc: Replaced O(n^2) strstr with O(n)

Took it from glibc.

Change-Id: Ide8866a8db81c3df99ebae65a0c35fe1a34679ce