summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2014-10-26 02:51:47 +0000
committerguenther <guenther@openbsd.org>2014-10-26 02:51:47 +0000
commitf0877b0ef4d74c1a11abbbd3e224af58ae4605bb (patch)
treeecde532d38e51a751883f5f75a9e86fa33847fbd
parenttimeout_mp() is static now (diff)
downloadwireguard-openbsd-f0877b0ef4d74c1a11abbbd3e224af58ae4605bb.tar.xz
wireguard-openbsd-f0877b0ef4d74c1a11abbbd3e224af58ae4605bb.zip
When regcomp() fails, use regerror() to get a useful error message
-rw-r--r--usr.sbin/amd/amd/mapc.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/usr.sbin/amd/amd/mapc.c b/usr.sbin/amd/amd/mapc.c
index 4ead96945dc..94a9e0d6b84 100644
--- a/usr.sbin/amd/amd/mapc.c
+++ b/usr.sbin/amd/amd/mapc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mapc.c,v 1.18 2014/10/26 02:43:50 guenther Exp $ */
+/* $OpenBSD: mapc.c,v 1.19 2014/10/26 02:51:47 guenther Exp $ */
/*-
* Copyright (c) 1989 Jan-Simon Pendry
@@ -248,19 +248,30 @@ mapc_add_kv(mnt_map *m, char *key, char *val)
if (MAPC_ISRE(m)) {
char keyb[MAXPATHLEN];
regex_t *re;
+ int err;
+
/*
* Make sure the string is bound to the start and end
*/
snprintf(keyb, sizeof(keyb), "^%s$", key);
re = malloc(sizeof(*re));
- if (!re || regcomp(re, keyb, 0)) {
+ if (re == NULL) {
+ plog(XLOG_USER, "error allocating RE \"%s\"", keyb);
+ return;
+ }
+ err = regcomp(re, keyb, 0);
+ if (err) {
+ char errbuf[100];
+
+ regerror(err, re, errbuf, sizeof errbuf);
free(re);
- plog(XLOG_USER, "error compiling RE \"%s\": %s", keyb);
+ plog(XLOG_USER, "error compiling RE \"%s\": %s",
+ keyb, errbuf);
return;
- } else {
- free(key);
- key = (char *)re;
}
+
+ free(key);
+ key = (char *)re;
}
h = &m->kvhash[hash];