diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-10-31 16:32:13 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-10-31 16:32:13 +0000 |
commit | 1f7b19cead218a460e128120285d1ed2b446d886 (patch) | |
tree | 674176ce5e406b8262b22a747e0520bcb052b4ee /usr.sbin/smtpd/util.c | |
parent | f10a43907cfeb0c66a5e76cddc1764869d79a748 (diff) |
add helper valid_smtp_response() to be used in upcoming commits
Diffstat (limited to 'usr.sbin/smtpd/util.c')
-rw-r--r-- | usr.sbin/smtpd/util.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index 3637d4dfff7..df7fabad782 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.137 2018/09/02 21:06:44 gilles Exp $ */ +/* $OpenBSD: util.c,v 1.138 2018/10/31 16:32:12 gilles Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -541,6 +541,21 @@ valid_domainpart(const char *s) } int +valid_smtp_response(const char *s) +{ + if (strlen(s) < 5) + return 0; + + if ((s[0] < '2' || s[0] > '5') || + (s[1] < '0' || s[1] > '9') || + (s[2] < '0' || s[2] > '9') || + (s[3] != ' ')) + return 0; + + return 1; +} + +int secure_file(int fd, char *path, char *userdir, uid_t uid, int mayread) { char buf[PATH_MAX]; |