mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-03-12 05:33:44 -04:00
topology: do not call strtol directly
Introduce safe_strtol_base() function and redirects all strtol calls there. Also, improve error and value handling in callers. BugLink: https://github.com/alsa-project/alsa-lib/issues/187 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
f547b2e35f
commit
5fab157a59
3 changed files with 40 additions and 19 deletions
|
|
@ -414,12 +414,8 @@ static int write_hex(char *buf, char *str, int width)
|
|||
void *p = &val;
|
||||
|
||||
errno = 0;
|
||||
val = strtol(str, NULL, 16);
|
||||
|
||||
if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
|
||||
|| (errno != 0 && val == 0)) {
|
||||
if (safe_strtol_base(str, &val, 16) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (width) {
|
||||
case 1:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue