summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2020-06-18 05:28:49 +0000
committerratchov <ratchov@openbsd.org>2020-06-18 05:28:49 +0000
commit2d7b56ac6e76659c2202dc82239745176acca661 (patch)
tree2cfd75d1d4b8a049413001f0e7c217ec2a5588ab /usr.bin
parentDon't try to open device that's already open (diff)
downloadwireguard-openbsd-2d7b56ac6e76659c2202dc82239745176acca661.tar.xz
wireguard-openbsd-2d7b56ac6e76659c2202dc82239745176acca661.zip
Allow names to start with digits or underscores
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/sndioctl/sndioctl.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/usr.bin/sndioctl/sndioctl.c b/usr.bin/sndioctl/sndioctl.c
index d04cbeb925d..44579dc423a 100644
--- a/usr.bin/sndioctl/sndioctl.c
+++ b/usr.bin/sndioctl/sndioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sndioctl.c,v 1.11 2020/05/25 09:14:50 mestre Exp $ */
+/* $OpenBSD: sndioctl.c,v 1.12 2020/06/18 05:28:49 ratchov Exp $ */
/*
* Copyright (c) 2014-2020 Alexandre Ratchov <alex@caoua.org>
*
@@ -69,15 +69,11 @@ struct info *infolist;
int i_flag = 0, v_flag = 0, m_flag = 0, n_flag = 0, q_flag = 0;
static inline int
-isname_first(int c)
+isname(int c)
{
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
-}
-
-static inline int
-isname_next(int c)
-{
- return isname_first(c) || (c >= '0' && c <= '9') || (c == '_');
+ return (c == '_') ||
+ (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9');
}
static int
@@ -481,11 +477,11 @@ parse_name(char **line, char *name)
char *p = *line;
unsigned len = 0;
- if (!isname_first(*p)) {
- fprintf(stderr, "letter expected near '%s'\n", p);
+ if (!isname(*p)) {
+ fprintf(stderr, "letter or digit expected near '%s'\n", p);
return 0;
}
- while (isname_next(*p)) {
+ while (isname(*p)) {
if (len >= SIOCTL_NAMEMAX - 1) {
name[SIOCTL_NAMEMAX - 1] = '\0';
fprintf(stderr, "%s...: too long\n", name);