Switch to use safe_strtoint instead of strtol

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Bryce Harrington
2016-08-03 17:40:52 -07:00
parent 82b9f2baec
commit 25a2bdd814
7 changed files with 21 additions and 34 deletions
+3 -4
View File
@@ -39,6 +39,7 @@
#include "xwayland.h"
#include "xwayland-api.h"
#include "shared/helpers.h"
#include "shared/string-helpers.h"
#include "compositor/weston.h"
static int
@@ -147,7 +148,7 @@ bind_to_unix_socket(int display)
static int
create_lockfile(int display, char *lockfile, size_t lsize)
{
char pid[16], *end;
char pid[16];
int fd, size;
pid_t other;
@@ -165,9 +166,7 @@ create_lockfile(int display, char *lockfile, size_t lsize)
return -1;
}
errno = 0;
other = strtol(pid, &end, 10);
if (errno != 0 || end == pid || *end != '\0') {
if (!safe_strtoint(pid, &other)) {
weston_log("can't parse lock file %s\n",
lockfile);
close(fd);