- namelen = strlen ((char *)p) + 1;
- section_len -= namelen + 4;
- if (std_section && strcmp ((char *)p, std_section) == 0)
+ section_len -= 4;
+ namelen = strnlen ((char *) p, section_len) + 1;
+ if (namelen == 0 || namelen >= section_len)
+ break;
+ section_len -= namelen;
+ if (std_sec && strcmp ((char *) p, std_sec) == 0)