summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-12-08 02:14:33 +0000
committerDamien Miller <djm@mindrot.org>2017-12-12 10:32:04 +1100
commitfd4eeeec16537870bd40d04836c7906ec141c17d (patch)
treed40133ba918cdf47f31d4278372a52441262a117 /misc.c
parent155072fdb0d938015df828836beb2f18a294ab8a (diff)
upstream commit
fix ordering in previous to ensure errno isn't clobbered before logging. OpenBSD-Commit-ID: e260bc1e145a9690dcb0d5aa9460c7b96a0c8ab2
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/misc.c b/misc.c
index 827b5a759..50988cefe 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.121 2017/12/08 02:13:02 djm Exp $ */ 1/* $OpenBSD: misc.c,v 1.122 2017/12/08 02:14:33 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -1515,18 +1515,18 @@ unix_listener(const char *path, int backlog, int unlink_first)
1515 } 1515 }
1516 if (bind(sock, (struct sockaddr *)&sunaddr, sizeof(sunaddr)) < 0) { 1516 if (bind(sock, (struct sockaddr *)&sunaddr, sizeof(sunaddr)) < 0) {
1517 saved_errno = errno; 1517 saved_errno = errno;
1518 close(sock);
1519 error("%s: cannot bind to path %s: %s", 1518 error("%s: cannot bind to path %s: %s",
1520 __func__, path, strerror(errno)); 1519 __func__, path, strerror(errno));
1520 close(sock);
1521 errno = saved_errno; 1521 errno = saved_errno;
1522 return -1; 1522 return -1;
1523 } 1523 }
1524 if (listen(sock, backlog) < 0) { 1524 if (listen(sock, backlog) < 0) {
1525 saved_errno = errno; 1525 saved_errno = errno;
1526 close(sock);
1527 unlink(path);
1528 error("%s: cannot listen on path %s: %s", 1526 error("%s: cannot listen on path %s: %s",
1529 __func__, path, strerror(errno)); 1527 __func__, path, strerror(errno));
1528 close(sock);
1529 unlink(path);
1530 errno = saved_errno; 1530 errno = saved_errno;
1531 return -1; 1531 return -1;
1532 } 1532 }