提交 f3bd362a 编写于 作者: J Jes Sorensen 提交者: Kevin Wolf

strtosz(): use unsigned char and switch to qemu_isspace()

isspace() behavior is undefined for signed char.

Bug pointed out by Eric Blake, thanks!
Signed-off-by: NJes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 45d1aa82
...@@ -294,7 +294,8 @@ int fcntl_setfl(int fd, int flag) ...@@ -294,7 +294,8 @@ int fcntl_setfl(int fd, int flag)
int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
{ {
int64_t retval = -1; int64_t retval = -1;
char *endptr, c, d; char *endptr;
unsigned char c, d;
int mul_required = 0; int mul_required = 0;
double val, mul, integral, fraction; double val, mul, integral, fraction;
...@@ -314,7 +315,7 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) ...@@ -314,7 +315,7 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
*/ */
c = *endptr; c = *endptr;
d = c; d = c;
if (isspace(c) || c == '\0' || c == ',') { if (qemu_isspace(c) || c == '\0' || c == ',') {
c = 0; c = 0;
if (default_suffix) { if (default_suffix) {
d = default_suffix; d = default_suffix;
...@@ -361,7 +362,7 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix) ...@@ -361,7 +362,7 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
*/ */
if (c != 0) { if (c != 0) {
endptr++; endptr++;
if (!isspace(*endptr) && *endptr != ',' && *endptr != 0) { if (!qemu_isspace(*endptr) && *endptr != ',' && *endptr != 0) {
goto fail; goto fail;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册