summaryrefslogtreecommitdiff
path: root/usr.sbin/rpki-client/validate.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/rpki-client/validate.c')
-rw-r--r--usr.sbin/rpki-client/validate.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.sbin/rpki-client/validate.c b/usr.sbin/rpki-client/validate.c
index 4677093f1b7..ca0312692d9 100644
--- a/usr.sbin/rpki-client/validate.c
+++ b/usr.sbin/rpki-client/validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: validate.c,v 1.31 2022/04/21 09:53:07 claudio Exp $ */
+/* $OpenBSD: validate.c,v 1.32 2022/05/10 07:41:37 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -275,6 +275,22 @@ valid_hash(unsigned char *buf, size_t len, const char *hash, size_t hlen)
}
/*
+ * Validate that a filename only contains characters from the POSIX portable
+ * filename character set [A-Za-z0-9._-], see IEEE Std 1003.1-2013, 3.278.
+ */
+int
+valid_filename(const char *fn, size_t len)
+{
+ const unsigned char *c;
+ size_t i;
+
+ for (c = fn, i = 0; i < len; i++, c++)
+ if (!isalnum(*c) && *c != '-' && *c != '_' && *c != '.')
+ return 0;
+ return 1;
+}
+
+/*
* Validate a URI to make sure it is pure ASCII and does not point backwards
* or doing some other silly tricks. To enforce the protocol pass either
* https:// or rsync:// as proto, if NULL is passed no protocol is enforced.