From 55e8e7af8b816be93bc32d9abaaee3f03b7032f2 Mon Sep 17 00:00:00 2001 From: Matthieu Herrb Date: Sat, 29 Jun 2019 20:29:49 +0000 Subject: check return values against -1 "reasonable" deraadt@ --- xenodm/auth.c | 9 ++++----- xenodm/dm.c | 2 +- xenodm/session.c | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/xenodm/auth.c b/xenodm/auth.c index 0f9528d..810f4cf 100644 --- a/xenodm/auth.c +++ b/xenodm/auth.c @@ -160,10 +160,10 @@ CheckServerAuthDir (const char *path, struct stat *statb, int mode) { int r = stat(path, statb); - if (r != 0) { + if (r == -1) { if (errno == ENOENT) { r = mkdir(path, mode); - if (r < 0) { + if (r == -1) { LogError ("cannot make authentication directory %s: %s\n", path, _SysErrorMsg (errno)); } else { @@ -180,7 +180,6 @@ CheckServerAuthDir (const char *path, struct stat *statb, int mode) return -1; } } - return r; } @@ -251,7 +250,7 @@ MakeServerAuthFile (struct display *d, FILE ** file, uid_t uid, gid_t gid) snprintf (d->authFile, len, "%s/%s/%s/A%s-XXXXXX", authDir, authdir1, authdir2, cleanname); fd = mkstemp (d->authFile); - if (fd < 0) { + if (fd == -1) { LogError ("cannot make authentication file %s: %s\n", d->authFile, _SysErrorMsg (errno)); free (d->authFile); @@ -670,7 +669,7 @@ DefineSelf(FILE *file, Xauth *auth) int family, len; Debug("DefineSelf\n"); - if (getifaddrs(&ifap) < 0) + if (getifaddrs(&ifap) == -1) return; for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) { len = sizeof(*(ifr->ifa_addr)); diff --git a/xenodm/dm.c b/xenodm/dm.c index 59a0307..aab2453 100644 --- a/xenodm/dm.c +++ b/xenodm/dm.c @@ -91,7 +91,7 @@ main (int argc, char **argv) exit (1); } if (debugLevel == 0 && daemonMode) { - if (daemon (0, 0) < 0) { + if (daemon (0, 0) == -1) { /* error */ LogError("daemon() failed, %s\n", _SysErrorMsg (errno)); exit(1); diff --git a/xenodm/session.c b/xenodm/session.c index 99ed59b..048d695 100644 --- a/xenodm/session.c +++ b/xenodm/session.c @@ -334,7 +334,7 @@ StartClient ( Debug("login_fbtab %s %d\n", d->windowPath, geteuid()); login_fbtab(d->windowPath, pwd->pw_uid, pwd->pw_gid); } - if (setusercontext(NULL, pwd, pwd->pw_uid, LOGIN_SETALL) < 0) { + if (setusercontext(NULL, pwd, pwd->pw_uid, LOGIN_SETALL) == -1) { LogError ("setusercontext for \"%s\" failed: %s\n", name, _SysErrorMsg (errno)); return (0); -- cgit v1.2.3