summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl
diff options
context:
space:
mode:
authorderaadt <>2019-06-28 13:35:02 +0000
committerderaadt <>2019-06-28 13:35:02 +0000
commit6585927e66d9ab172754d95c4296dd4309a40512 (patch)
treebc969c069c7b769f2601db17f08bec99274202a5 /src/usr.bin/openssl
parent74ff76124ba7a371400a9f60d5e33192a3732f03 (diff)
downloadopenbsd-6585927e66d9ab172754d95c4296dd4309a40512.tar.gz
openbsd-6585927e66d9ab172754d95c4296dd4309a40512.tar.bz2
openbsd-6585927e66d9ab172754d95c4296dd4309a40512.zip
When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
Diffstat (limited to 'src/usr.bin/openssl')
-rw-r--r--src/usr.bin/openssl/apps.c28
-rw-r--r--src/usr.bin/openssl/s_client.c6
-rw-r--r--src/usr.bin/openssl/s_server.c4
-rw-r--r--src/usr.bin/openssl/s_socket.c8
4 files changed, 23 insertions, 23 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c
index 2297b5bf2b..47e21265af 100644
--- a/src/usr.bin/openssl/apps.c
+++ b/src/usr.bin/openssl/apps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: apps.c,v 1.51 2019/02/09 15:49:21 inoguchi Exp $ */ 1/* $OpenBSD: apps.c,v 1.52 2019/06/28 13:35:02 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -1377,7 +1377,7 @@ rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
1377 goto err; 1377 goto err;
1378 } 1378 }
1379 1379
1380 if (rename(serialfile, opath) < 0 && 1380 if (rename(serialfile, opath) == -1 &&
1381 errno != ENOENT && errno != ENOTDIR) { 1381 errno != ENOENT && errno != ENOTDIR) {
1382 BIO_printf(bio_err, "unable to rename %s to %s\n", 1382 BIO_printf(bio_err, "unable to rename %s to %s\n",
1383 serialfile, opath); 1383 serialfile, opath);
@@ -1386,11 +1386,11 @@ rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
1386 } 1386 }
1387 1387
1388 1388
1389 if (rename(npath, serialfile) < 0) { 1389 if (rename(npath, serialfile) == -1) {
1390 BIO_printf(bio_err, "unable to rename %s to %s\n", 1390 BIO_printf(bio_err, "unable to rename %s to %s\n",
1391 npath, serialfile); 1391 npath, serialfile);
1392 perror("reason"); 1392 perror("reason");
1393 if (rename(opath, serialfile) < 0) { 1393 if (rename(opath, serialfile) == -1) {
1394 BIO_printf(bio_err, "unable to rename %s to %s\n", 1394 BIO_printf(bio_err, "unable to rename %s to %s\n",
1395 opath, serialfile); 1395 opath, serialfile);
1396 perror("reason"); 1396 perror("reason");
@@ -1599,18 +1599,18 @@ rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix)
1599 goto err; 1599 goto err;
1600 } 1600 }
1601 1601
1602 if (rename(dbfile, odbpath) < 0 && errno != ENOENT && errno != ENOTDIR) { 1602 if (rename(dbfile, odbpath) == -1 && errno != ENOENT && errno != ENOTDIR) {
1603 BIO_printf(bio_err, "unable to rename %s to %s\n", 1603 BIO_printf(bio_err, "unable to rename %s to %s\n",
1604 dbfile, odbpath); 1604 dbfile, odbpath);
1605 perror("reason"); 1605 perror("reason");
1606 goto err; 1606 goto err;
1607 } 1607 }
1608 1608
1609 if (rename(dbpath, dbfile) < 0) { 1609 if (rename(dbpath, dbfile) == -1) {
1610 BIO_printf(bio_err, "unable to rename %s to %s\n", 1610 BIO_printf(bio_err, "unable to rename %s to %s\n",
1611 dbpath, dbfile); 1611 dbpath, dbfile);
1612 perror("reason"); 1612 perror("reason");
1613 if (rename(odbpath, dbfile) < 0) { 1613 if (rename(odbpath, dbfile) == -1) {
1614 BIO_printf(bio_err, "unable to rename %s to %s\n", 1614 BIO_printf(bio_err, "unable to rename %s to %s\n",
1615 odbpath, dbfile); 1615 odbpath, dbfile);
1616 perror("reason"); 1616 perror("reason");
@@ -1618,16 +1618,16 @@ rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix)
1618 goto err; 1618 goto err;
1619 } 1619 }
1620 1620
1621 if (rename(attrpath, oattrpath) < 0 && errno != ENOENT && errno != ENOTDIR) { 1621 if (rename(attrpath, oattrpath) == -1 && errno != ENOENT && errno != ENOTDIR) {
1622 BIO_printf(bio_err, "unable to rename %s to %s\n", 1622 BIO_printf(bio_err, "unable to rename %s to %s\n",
1623 attrpath, oattrpath); 1623 attrpath, oattrpath);
1624 perror("reason"); 1624 perror("reason");
1625 if (rename(dbfile, dbpath) < 0) { 1625 if (rename(dbfile, dbpath) == -1) {
1626 BIO_printf(bio_err, "unable to rename %s to %s\n", 1626 BIO_printf(bio_err, "unable to rename %s to %s\n",
1627 dbfile, dbpath); 1627 dbfile, dbpath);
1628 perror("reason"); 1628 perror("reason");
1629 } 1629 }
1630 if (rename(odbpath, dbfile) < 0) { 1630 if (rename(odbpath, dbfile) == -1) {
1631 BIO_printf(bio_err, "unable to rename %s to %s\n", 1631 BIO_printf(bio_err, "unable to rename %s to %s\n",
1632 odbpath, dbfile); 1632 odbpath, dbfile);
1633 perror("reason"); 1633 perror("reason");
@@ -1635,21 +1635,21 @@ rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix)
1635 goto err; 1635 goto err;
1636 } 1636 }
1637 1637
1638 if (rename(nattrpath, attrpath) < 0) { 1638 if (rename(nattrpath, attrpath) == -1) {
1639 BIO_printf(bio_err, "unable to rename %s to %s\n", 1639 BIO_printf(bio_err, "unable to rename %s to %s\n",
1640 nattrpath, attrpath); 1640 nattrpath, attrpath);
1641 perror("reason"); 1641 perror("reason");
1642 if (rename(oattrpath, attrpath) < 0) { 1642 if (rename(oattrpath, attrpath) == -1) {
1643 BIO_printf(bio_err, "unable to rename %s to %s\n", 1643 BIO_printf(bio_err, "unable to rename %s to %s\n",
1644 oattrpath, attrpath); 1644 oattrpath, attrpath);
1645 perror("reason"); 1645 perror("reason");
1646 } 1646 }
1647 if (rename(dbfile, dbpath) < 0) { 1647 if (rename(dbfile, dbpath) == -1) {
1648 BIO_printf(bio_err, "unable to rename %s to %s\n", 1648 BIO_printf(bio_err, "unable to rename %s to %s\n",
1649 dbfile, dbpath); 1649 dbfile, dbpath);
1650 perror("reason"); 1650 perror("reason");
1651 } 1651 }
1652 if (rename(odbpath, dbfile) < 0) { 1652 if (rename(odbpath, dbfile) == -1) {
1653 BIO_printf(bio_err, "unable to rename %s to %s\n", 1653 BIO_printf(bio_err, "unable to rename %s to %s\n",
1654 odbpath, dbfile); 1654 odbpath, dbfile);
1655 perror("reason"); 1655 perror("reason");
diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c
index e542f08481..23bf67e695 100644
--- a/src/usr.bin/openssl/s_client.c
+++ b/src/usr.bin/openssl/s_client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_client.c,v 1.37 2018/11/14 06:24:21 tb Exp $ */ 1/* $OpenBSD: s_client.c,v 1.38 2019/06/28 13:35:02 deraadt Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -759,7 +759,7 @@ re_start:
759 if (SSL_version(con) == DTLS1_VERSION) { 759 if (SSL_version(con) == DTLS1_VERSION) {
760 760
761 sbio = BIO_new_dgram(s, BIO_NOCLOSE); 761 sbio = BIO_new_dgram(s, BIO_NOCLOSE);
762 if (getsockname(s, &peer, (void *) &peerlen) < 0) { 762 if (getsockname(s, &peer, (void *) &peerlen) == -1) {
763 BIO_printf(bio_err, "getsockname:errno=%d\n", 763 BIO_printf(bio_err, "getsockname:errno=%d\n",
764 errno); 764 errno);
765 shutdown(s, SHUT_RD); 765 shutdown(s, SHUT_RD);
@@ -1013,7 +1013,7 @@ re_start:
1013 tty_on,read_tty,write_tty,read_ssl,write_ssl);*/ 1013 tty_on,read_tty,write_tty,read_ssl,write_ssl);*/
1014 1014
1015 i = poll(pfd, 3, ptimeout); 1015 i = poll(pfd, 3, ptimeout);
1016 if (i < 0) { 1016 if (i == -1) {
1017 BIO_printf(bio_err, "bad select %d\n", 1017 BIO_printf(bio_err, "bad select %d\n",
1018 errno); 1018 errno);
1019 goto shut; 1019 goto shut;
diff --git a/src/usr.bin/openssl/s_server.c b/src/usr.bin/openssl/s_server.c
index 4bdafaf682..a15795151f 100644
--- a/src/usr.bin/openssl/s_server.c
+++ b/src/usr.bin/openssl/s_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_server.c,v 1.30 2018/02/07 05:47:55 jsing Exp $ */ 1/* $OpenBSD: s_server.c,v 1.31 2019/06/28 13:35:02 deraadt Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1512,7 +1512,7 @@ sv_body(char *hostname, int s, unsigned char *context)
1512 n = write(fileno(stdout), buf + len, i - len); 1512 n = write(fileno(stdout), buf + len, i - len);
1513 } while (n == -1 && errno == EINTR); 1513 } while (n == -1 && errno == EINTR);
1514 1514
1515 if (n < 0) { 1515 if (n == -1) {
1516 BIO_printf(bio_s_out, "ERROR\n"); 1516 BIO_printf(bio_s_out, "ERROR\n");
1517 goto err; 1517 goto err;
1518 } 1518 }
diff --git a/src/usr.bin/openssl/s_socket.c b/src/usr.bin/openssl/s_socket.c
index 62b32d3936..5d90fad8bb 100644
--- a/src/usr.bin/openssl/s_socket.c
+++ b/src/usr.bin/openssl/s_socket.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_socket.c,v 1.10 2018/08/19 20:07:06 tb Exp $ */ 1/* $OpenBSD: s_socket.c,v 1.11 2019/06/28 13:35:02 deraadt Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -107,7 +107,7 @@ init_client(int *sock, char *host, char *port, int type, int af)
107 i = 0; 107 i = 0;
108 i = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, 108 i = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,
109 (char *) &i, sizeof(i)); 109 (char *) &i, sizeof(i));
110 if (i < 0) { 110 if (i == -1) {
111 perror("keepalive"); 111 perror("keepalive");
112 goto out; 112 goto out;
113 } 113 }
@@ -251,10 +251,10 @@ do_accept(int acc_sock, int *sock, char **host)
251 ling.l_onoff=1; 251 ling.l_onoff=1;
252 ling.l_linger=0; 252 ling.l_linger=0;
253 i=setsockopt(ret,SOL_SOCKET,SO_LINGER,(char *)&ling,sizeof(ling)); 253 i=setsockopt(ret,SOL_SOCKET,SO_LINGER,(char *)&ling,sizeof(ling));
254 if (i < 0) { perror("linger"); return(0); } 254 if (i == -1) { perror("linger"); return(0); }
255 i=0; 255 i=0;
256 i=setsockopt(ret,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i)); 256 i=setsockopt(ret,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
257 if (i < 0) { perror("keepalive"); return(0); } 257 if (i == -1) { perror("keepalive"); return(0); }
258*/ 258*/
259 259
260 if (host == NULL) 260 if (host == NULL)