summaryrefslogtreecommitdiffstats
path: root/lib/libsndio
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libsndio')
-rw-r--r--lib/libsndio/aucat.c27
-rw-r--r--lib/libsndio/debug.c10
2 files changed, 10 insertions, 27 deletions
diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c
index f2d9cd559b9..7a439e34e49 100644
--- a/lib/libsndio/aucat.c
+++ b/lib/libsndio/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.72 2018/07/28 09:11:55 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.73 2018/09/26 08:33:22 miko Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -388,27 +388,6 @@ aucat_connect_un(struct aucat *hdl, unsigned int unit)
}
static const char *
-parsedev(const char *str, unsigned int *rval)
-{
- const char *p = str;
- unsigned int val;
-
- for (val = 0; *p >= '0' && *p <= '9'; p++) {
- val = 10 * val + (*p - '0');
- if (val >= 16) {
- DPRINTF("%s: number too large\n", str);
- return NULL;
- }
- }
- if (p == str) {
- DPRINTF("%s: number expected\n", str);
- return NULL;
- }
- *rval = val;
- return p;
-}
-
-static const char *
parsestr(const char *str, char *rstr, unsigned int max)
{
const char *p = str;
@@ -454,7 +433,7 @@ _aucat_open(struct aucat *hdl, const char *str, unsigned int mode)
} else
*host = '\0';
if (*p == ',') {
- p = parsedev(++p, &unit);
+ p = _sndio_parsenum(++p, &unit, 15);
if (p == NULL)
return 0;
} else
@@ -463,7 +442,7 @@ _aucat_open(struct aucat *hdl, const char *str, unsigned int mode)
DPRINTF("%s: '/' expected\n", str);
return 0;
}
- p = parsedev(++p, &devnum);
+ p = _sndio_parsenum(++p, &devnum, 15);
if (p == NULL)
return 0;
if (*p == '.') {
diff --git a/lib/libsndio/debug.c b/lib/libsndio/debug.c
index 6940ca9b909..f07ed81dfa5 100644
--- a/lib/libsndio/debug.c
+++ b/lib/libsndio/debug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: debug.c,v 1.4 2015/10/02 09:48:22 ratchov Exp $ */
+/* $OpenBSD: debug.c,v 1.5 2018/09/26 08:33:22 miko Exp $ */
/*
* Copyright (c) 2011 Alexandre Ratchov <alex@caoua.org>
*
@@ -67,13 +67,17 @@ _sndio_parsenum(const char *str, unsigned int *num, unsigned int max)
dig = *p - '0';
if (dig >= 10)
break;
- if (val > maxq || (val == maxq && dig > maxr))
+ if (val > maxq || (val == maxq && dig > maxr)) {
+ DPRINTF("%s: number too large\n", str);
return NULL;
+ }
val = val * 10 + dig;
p++;
}
- if (p == str)
+ if (p == str) {
+ DPRINTF("%s: number expected\n", str);
return NULL;
+ }
*num = val;
return p;
}