mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
scanner, client: Added more error checks when strtol function is used
Signed-off-by: Imran Zaman <imran.zaman@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
ca0ee83157
commit
3170fdfbc3
2 changed files with 7 additions and 2 deletions
|
|
@ -404,11 +404,13 @@ start_element(void *data, const char *element_name, const char **atts)
|
||||||
message->destructor = 0;
|
message->destructor = 0;
|
||||||
|
|
||||||
if (since != NULL) {
|
if (since != NULL) {
|
||||||
|
int prev_errno = errno;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
version = strtol(since, &end, 0);
|
version = strtol(since, &end, 0);
|
||||||
if (errno == EINVAL || end == since || *end != '\0')
|
if (errno != 0 || end == since || *end != '\0')
|
||||||
fail(&ctx->loc,
|
fail(&ctx->loc,
|
||||||
"invalid integer (%s)\n", since);
|
"invalid integer (%s)\n", since);
|
||||||
|
errno = prev_errno;
|
||||||
} else {
|
} else {
|
||||||
version = 1;
|
version = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -829,9 +829,12 @@ wl_display_connect(const char *name)
|
||||||
|
|
||||||
connection = getenv("WAYLAND_SOCKET");
|
connection = getenv("WAYLAND_SOCKET");
|
||||||
if (connection) {
|
if (connection) {
|
||||||
|
int prev_errno = errno;
|
||||||
|
errno = 0;
|
||||||
fd = strtol(connection, &end, 0);
|
fd = strtol(connection, &end, 0);
|
||||||
if (*end != '\0')
|
if (errno != 0 || connection == end || *end != '\0')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
errno = prev_errno;
|
||||||
|
|
||||||
flags = fcntl(fd, F_GETFD);
|
flags = fcntl(fd, F_GETFD);
|
||||||
if (flags != -1)
|
if (flags != -1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue