Skip to contentSkip to conversation

New command to check NT's hibernation state

DISCUSSION Peter Lustig 2 participants 3 messages Dec 23, 2011 – Jan 28, 2013 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
Quoted 2 lines · Peter Lustig
Quoted 2 lines

/* 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 <http://www.msuiche.net/pres/PacSec07-slides-0.4.pdf>) 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.

#2 lore raw
Quoted 9 lines · Peter Lustig
Quoted 7 lines · Vladimir 'phcoder' Serbinenko
Quoted 3 lines · Peter Lustig
Quoted 1 line
     /* Return SUCCESS if magic indicates file is active; else 

return FAILURE */

Quoted 1 line

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 <http://www.msuiche.net/pres/PacSec07-slides-0.4.pdf>) 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.

Sorry to bump this thread. Do you know if there are any plans to include the 'nthibr' module in a future release of GRUB. I looked and didn't see any references to it in the Bazaar trunk.

#3 lore raw
In reply to Peter Lustig
Quoted 8 lines · Peter Lustig
Quoted 7 lines · Vladimir 'phcoder' Serbinenko
Quoted 3 lines · Peter Lustig
Quoted 1 line
     /* Return SUCCESS if magic indicates file is active; else

return FAILURE */

Quoted 1 line

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.

Quoted 9 lines

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
<http://www.msuiche.net/pres/PacSec07-slides-0.4.pdf>) 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.

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko