Index: textfile.c =================================================================== RCS file: /cvsroot/bluez/utils/common/textfile.c,v retrieving revision 1.16 diff -u -r1.16 textfile.c --- textfile.c 24 Mar 2006 14:36:28 -0000 1.16 +++ textfile.c 3 Apr 2006 06:58:46 -0000 @@ -86,9 +86,17 @@ return 0; } -static inline char *find_key(char *map, const char *key, size_t len) +static inline char *find_key(char *map, size_t maplen, const char *key, size_t len) { - char *off = strstr(map, key); + char *off = NULL; + int start=0; + while (start < (maplen - len)) { + if (0 == strncmp(map+start, key, len)) { + off = map + start; + break; + } + start++; + } while (off && ((off > map && *(off - 1) != '\r' && *(off - 1) != '\n') || *(off + len) != ' ')) @@ -156,7 +164,7 @@ goto unlock; } - off = find_key(map, key, strlen(key)); + off = find_key(map, size, key, strlen(key)); if (!off) { if (value) { munmap(map, size); @@ -265,7 +273,7 @@ } len = strlen(key); - off = find_key(map, key, len); + off = find_key(map, size, key, len); if (!off) { err = EILSEQ; goto unmap;