We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3e4fbdb commit e5629b7Copy full SHA for e5629b7
libyara/exefiles.c
@@ -139,14 +139,30 @@ int yr_get_elf_type(
139
140
elf_ident = (elf_ident_t*) buffer;
141
142
- if (yr_le32toh(elf_ident->magic) == ELF_MAGIC)
143
- {
144
- return elf_ident->_class;
145
- }
146
- else
+ if (yr_le32toh(elf_ident->magic) != ELF_MAGIC)
147
{
148
return 0;
149
}
+
+ switch (elf_ident->_class) {
+ case ELF_CLASS_32:
+ if (buffer_length < sizeof(elf32_header_t))
150
+ {
151
+ return 0;
152
+ }
153
+ break;
154
+ case ELF_CLASS_64:
155
+ if (buffer_length < sizeof(elf64_header_t))
156
157
158
159
160
+ default:
161
+ /* Unexpected class */
162
163
164
165
+ return elf_ident->_class;
166
167
168
0 commit comments