On 23.12.2011 05:32, Peter Lustig wrote: > On 12/22/2011 13:10, Vladimir 'phcoder' Serbinenko wrote: >> On 18.12.2011 04:16, Peter Lustig wrote: >>> > /* Return SUCCESS if magic indicates file is active; else >>> return FAILURE */ >>> > if (!grub_strncasecmp ("hibr", hibr_file_magic, magic_size)) >> What's the reason to use strncasecmp? Does the case changes? Usually >> memcmp is the right way to check the signature. This also avoids the >> need of memset and trailing zero byte. > It can be either {'h', 'i', 'b', 'r'} (for Windows XP) or {'H', 'I', > 'B', 'R'} (for Windows Vista/7). Technically I should only be checking > for these two values, but it is unlikely that the magic would have mixed > case. The only other values I know (from > ) that it can > assume are {'w', 'a', 'k', 'e'}, {'l', 'i', 'n', 'k'}, and {'\0', '\0', > '\0', '\0'}. Using strncasecmp() seemed like a simple way to approach > the problem. > strncasecmp isn't for comparing te binary strings. In GRUB it's fairly simplistic but this is conceptually wrong. Conceptually híbr and HIBR would match even if GRUB currently doesn't do this kind of handling. > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel > -- Regards Vladimir 'φ-coder/phcoder' Serbinenko