From 39339e78fa3cf6f5639ec222befd248e06ea5b5c Mon Sep 17 00:00:00 2001 From: deraadt Date: Sat, 21 May 2022 01:21:29 +0000 Subject: [PATCH] repair a few more backwards compares that create headaches ok millert --- usr.sbin/cron/do_command.c | 10 +++++----- usr.sbin/cron/entry.c | 18 +++++++++--------- usr.sbin/cron/env.c | 4 ++-- usr.sbin/cron/misc.c | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c index 603cb1bd210..df461b7b7f0 100644 --- a/usr.sbin/cron/do_command.c +++ b/usr.sbin/cron/do_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: do_command.c,v 1.62 2022/01/28 06:33:27 guenther Exp $ */ +/* $OpenBSD: do_command.c,v 1.63 2022/05/21 01:21:29 deraadt Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -128,8 +128,8 @@ child_process(entry *e, user *u) char *p; for (input_data = p = e->cmd; - (ch = *input_data) != '\0'; - input_data++, p++) { + (ch = *input_data) != '\0'; + input_data++, p++) { if (p != input_data) *p = ch; if (escaped) { @@ -416,7 +416,7 @@ child_process(entry *e, user *u) * mail pipe if we ARE mailing. */ - while (EOF != (ch = getc(in))) { + while ((ch = getc(in)) != EOF) { bytes++; if (mail) fputc(ch, mail); @@ -475,7 +475,7 @@ child_process(entry *e, user *u) int safe_p(const char *usernm, const char *s) { - static const char safe_delim[] = "@!:%+-.,"; /* conservative! */ + static const char safe_delim[] = "@!:%+-.,"; /* conservative! */ const char *t; int ch, first; diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c index af564e1762d..ab683b8476a 100644 --- a/usr.sbin/cron/entry.c +++ b/usr.sbin/cron/entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entry.c,v 1.52 2020/04/18 16:19:02 deraadt Exp $ */ +/* $OpenBSD: entry.c,v 1.53 2022/05/21 01:21:29 deraadt Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -191,7 +191,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, if (ch == '*') e->flags |= MIN_STAR; ch = get_list(e->minute, FIRST_MINUTE, LAST_MINUTE, - NULL, ch, file); + NULL, ch, file); if (ch == EOF) { ecode = e_minute; goto eof; @@ -203,7 +203,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, if (ch == '*') e->flags |= HR_STAR; ch = get_list(e->hour, FIRST_HOUR, LAST_HOUR, - NULL, ch, file); + NULL, ch, file); if (ch == EOF) { ecode = e_hour; goto eof; @@ -215,7 +215,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, if (ch == '*') e->flags |= DOM_STAR; ch = get_list(e->dom, FIRST_DOM, LAST_DOM, - NULL, ch, file); + NULL, ch, file); if (ch == EOF) { ecode = e_dom; goto eof; @@ -225,7 +225,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, */ ch = get_list(e->month, FIRST_MONTH, LAST_MONTH, - MonthNames, ch, file); + MonthNames, ch, file); if (ch == EOF) { ecode = e_month; goto eof; @@ -237,7 +237,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, if (ch == '*') e->flags |= DOW_STAR; ch = get_list(e->dow, FIRST_DOW, LAST_DOW, - DowNames, ch, file); + DowNames, ch, file); if (ch == EOF) { ecode = e_dow; goto eof; @@ -432,7 +432,7 @@ get_list(bitstr_t *bits, int low, int high, const char *names[], */ done = FALSE; while (!done) { - if (EOF == (ch = get_range(bits, low, high, names, ch, file))) + if ((ch = get_range(bits, low, high, names, ch, file)) == EOF) return (EOF); if (ch == ',') ch = get_char(file); @@ -513,7 +513,7 @@ get_range(bitstr_t *bits, int low, int high, const char *names[], default: /* not a range, it's a single number. */ - if (EOF == set_element(bits, low, high, num1)) { + if (set_element(bits, low, high, num1) == EOF) { unget_char(ch, file); return (EOF); } @@ -550,7 +550,7 @@ get_range(bitstr_t *bits, int low, int high, const char *names[], * designed then implemented by paul vixie). */ for (i = num1; i <= num2; i += num3) - if (EOF == set_element(bits, low, high, i)) { + if (set_element(bits, low, high, i) == EOF) { unget_char(ch, file); return (EOF); } diff --git a/usr.sbin/cron/env.c b/usr.sbin/cron/env.c index a26277da4e1..19ef9908861 100644 --- a/usr.sbin/cron/env.c +++ b/usr.sbin/cron/env.c @@ -1,4 +1,4 @@ -/* $OpenBSD: env.c,v 1.33 2017/06/07 23:36:43 millert Exp $ */ +/* $OpenBSD: env.c,v 1.34 2022/05/21 01:21:29 deraadt Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -165,7 +165,7 @@ load_env(char *envstr, FILE *f) filepos = ftell(f); fileline = LineNumber; skip_comments(f); - if (EOF == get_string(envstr, MAX_ENVSTR, f, "\n")) + if (get_string(envstr, MAX_ENVSTR, f, "\n") == EOF) return (-1); bzero(name, sizeof name); diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c index 8e0865d0a85..b825d5b1be7 100644 --- a/usr.sbin/cron/misc.c +++ b/usr.sbin/cron/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.71 2015/11/14 13:09:14 millert Exp $ */ +/* $OpenBSD: misc.c,v 1.72 2022/05/21 01:21:29 deraadt Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -67,7 +67,7 @@ get_string(char *string, int size, FILE *file, char *terms) { int ch; - while (EOF != (ch = get_char(file)) && !strchr(terms, ch)) { + while ((ch = get_char(file)) != EOF && !strchr(terms, ch)) { if (size > 1) { *string++ = ch; size--; @@ -87,7 +87,7 @@ skip_comments(FILE *file) { int ch; - while (EOF != (ch = get_char(file))) { + while ((ch = get_char(file)) != EOF) { /* ch is now the first character of a line. */ -- 2.20.1