Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
ef5f90e4
Commit
ef5f90e4
authored
Oct 02, 2015
by
Matthias Braun
Browse files
libcore: Fix out of bounds read
... by rewriting stupid code.
parent
2f546a03
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/libcore/lc_opts.c
View file @
ef5f90e4
...
...
@@ -246,11 +246,13 @@ lc_opt_entry_t *lc_opt_resolve_opt(const lc_opt_entry_t *root,
return
lc_opt_find_opt
(
grp
,
names
[
n
-
1
]);
}
static
char
*
strtolower
(
char
*
buf
,
size_t
n
,
const
char
*
s
tr
)
static
bool
streq_lower
(
const
char
*
s0
,
const
char
*
s
1
)
{
for
(
unsigned
i
=
0
;
i
<
n
;
++
i
)
buf
[
i
]
=
tolower
((
unsigned
char
)
str
[
i
]);
return
buf
;
for
(
;
*
s0
!=
'\0'
&&
*
s1
!=
'\0'
;
++
s0
,
++
s1
)
{
if
(
tolower
((
unsigned
char
)
*
s0
)
!=
tolower
((
unsigned
char
)
*
s1
))
return
false
;
}
return
*
s0
==
*
s1
;
}
static
bool
string_to_bool
(
bool
*
const
val
,
char
const
*
const
value
)
...
...
@@ -269,10 +271,8 @@ static bool string_to_bool(bool *const val, char const *const value)
{
"0"
,
0
},
};
char
buf
[
16
];
strtolower
(
buf
,
sizeof
(
buf
),
value
);
for
(
unsigned
i
=
0
;
i
<
ARRAY_SIZE
(
bool_strings
);
++
i
)
{
if
(
str
cmp
(
buf
,
bool_strings
[
i
].
str
)
==
0
)
{
if
(
str
eq_lower
(
value
,
bool_strings
[
i
].
str
))
{
*
val
=
bool_strings
[
i
].
val
;
return
true
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment