Look for nulls as well and don't use strpbrk().