summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2017-05-27 08:31:09 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2017-05-27 08:31:09 +0000
commit1b5fd98198f2adb6d2d152c115dca82f396d1c11 (patch)
tree53e41947e989697d1bdf5402582fcb0c60bf9709
parentbfddcde5f6ac3017d223b4a7b46a3a4666956dc1 (diff)
Use basename(3) instead of hand rolling it.
Gets rid of double slashes, pointed out by Raf Czlonka (rczlonka at gmail), thanks! OK benno
-rw-r--r--usr.sbin/acme-client/main.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/usr.sbin/acme-client/main.c b/usr.sbin/acme-client/main.c
index f8dc22c8756..a6ce6190b8a 100644
--- a/usr.sbin/acme-client/main.c
+++ b/usr.sbin/acme-client/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.34 2017/03/23 12:58:28 florian Exp $ */
+/* $Id: main.c,v 1.35 2017/05/27 08:31:08 florian Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -128,23 +128,19 @@ main(int argc, char *argv[])
}
if(domain->chain != NULL) {
- if ((chainfile = strstr(domain->chain, certdir)) != NULL)
- chainfile = domain->chain + strlen(certdir);
- else
- chainfile = domain->chain;
-
- if ((chainfile = strdup(chainfile)) == NULL)
- err(EXIT_FAILURE, "strdup");
+ if ((chainfile = basename(domain->chain)) != NULL) {
+ if ((chainfile = strdup(chainfile)) == NULL)
+ err(EXIT_FAILURE, "strdup");
+ } else
+ err(EXIT_FAILURE, "basename");
}
if(domain->fullchain != NULL) {
- if ((fullchainfile = strstr(domain->fullchain, certdir)) != NULL)
- fullchainfile = domain->fullchain + strlen(certdir);
- else
- fullchainfile = domain->fullchain;
-
- if ((fullchainfile = strdup(fullchainfile)) == NULL)
- err(EXIT_FAILURE, "strdup");
+ if ((fullchainfile = basename(domain->fullchain)) != NULL) {
+ if ((fullchainfile = strdup(fullchainfile)) == NULL)
+ err(EXIT_FAILURE, "strdup");
+ } else
+ err(EXIT_FAILURE, "basename");
}
if ((auth = domain->auth) == NULL) {