diff options
author | doug <> | 2015-07-20 02:41:10 +0000 |
---|---|---|
committer | doug <> | 2015-07-20 02:41:10 +0000 |
commit | 9a0c50924ad1a4ad25acfcb4f9170bcae57ef3e7 (patch) | |
tree | 9c673ab6ea48305fa9892aaf8420ba5c99df1620 /src | |
parent | fbc67b2d2e682a513c9274c360fbb0ba7409639f (diff) | |
download | openbsd-9a0c50924ad1a4ad25acfcb4f9170bcae57ef3e7.tar.gz openbsd-9a0c50924ad1a4ad25acfcb4f9170bcae57ef3e7.tar.bz2 openbsd-9a0c50924ad1a4ad25acfcb4f9170bcae57ef3e7.zip |
Warn when rename() fails in openssl(1) apps.
Fixes Coverity issues 78795 and 78803.
ok bcook@
Diffstat (limited to 'src')
-rw-r--r-- | src/usr.bin/openssl/apps.c | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c index 16b76ae346..230ebd5a42 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.29 2015/07/16 15:03:35 beck Exp $ */ | 1 | /* $OpenBSD: apps.c,v 1.30 2015/07/20 02:41:10 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -1510,7 +1510,11 @@ rotate_serial(char *serialfile, char *new_suffix, char *old_suffix) | |||
1510 | BIO_printf(bio_err, "unable to rename %s to %s\n", | 1510 | BIO_printf(bio_err, "unable to rename %s to %s\n", |
1511 | buf[0], serialfile); | 1511 | buf[0], serialfile); |
1512 | perror("reason"); | 1512 | perror("reason"); |
1513 | rename(buf[1], serialfile); | 1513 | if (rename(buf[1], serialfile) < 0) { |
1514 | BIO_printf(bio_err, "unable to rename %s to %s\n", | ||
1515 | buf[1], serialfile); | ||
1516 | perror("reason"); | ||
1517 | } | ||
1514 | goto err; | 1518 | goto err; |
1515 | } | 1519 | } |
1516 | return 1; | 1520 | return 1; |
@@ -1714,7 +1718,11 @@ rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix) | |||
1714 | BIO_printf(bio_err, "unable to rename %s to %s\n", | 1718 | BIO_printf(bio_err, "unable to rename %s to %s\n", |
1715 | buf[0], dbfile); | 1719 | buf[0], dbfile); |
1716 | perror("reason"); | 1720 | perror("reason"); |
1717 | rename(buf[1], dbfile); | 1721 | if (rename(buf[1], dbfile) < 0) { |
1722 | BIO_printf(bio_err, "unable to rename %s to %s\n", | ||
1723 | buf[1], dbfile); | ||
1724 | perror("reason"); | ||
1725 | } | ||
1718 | goto err; | 1726 | goto err; |
1719 | } | 1727 | } |
1720 | 1728 | ||
@@ -1723,8 +1731,16 @@ rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix) | |||
1723 | BIO_printf(bio_err, "unable to rename %s to %s\n", | 1731 | BIO_printf(bio_err, "unable to rename %s to %s\n", |
1724 | buf[4], buf[3]); | 1732 | buf[4], buf[3]); |
1725 | perror("reason"); | 1733 | perror("reason"); |
1726 | rename(dbfile, buf[0]); | 1734 | if (rename(dbfile, buf[0]) < 0) { |
1727 | rename(buf[1], dbfile); | 1735 | BIO_printf(bio_err, "unable to rename %s to %s\n", |
1736 | dbfile, buf[0]); | ||
1737 | perror("reason"); | ||
1738 | } | ||
1739 | if (rename(buf[1], dbfile) < 0) { | ||
1740 | BIO_printf(bio_err, "unable to rename %s to %s\n", | ||
1741 | buf[1], dbfile); | ||
1742 | perror("reason"); | ||
1743 | } | ||
1728 | goto err; | 1744 | goto err; |
1729 | } | 1745 | } |
1730 | 1746 | ||
@@ -1733,9 +1749,21 @@ rotate_index(const char *dbfile, const char *new_suffix, const char *old_suffix) | |||
1733 | BIO_printf(bio_err, "unable to rename %s to %s\n", | 1749 | BIO_printf(bio_err, "unable to rename %s to %s\n", |
1734 | buf[2], buf[4]); | 1750 | buf[2], buf[4]); |
1735 | perror("reason"); | 1751 | perror("reason"); |
1736 | rename(buf[3], buf[4]); | 1752 | if (rename(buf[3], buf[4]) < 0) { |
1737 | rename(dbfile, buf[0]); | 1753 | BIO_printf(bio_err, "unable to rename %s to %s\n", |
1738 | rename(buf[1], dbfile); | 1754 | buf[3], buf[4]); |
1755 | perror("reason"); | ||
1756 | } | ||
1757 | if (rename(dbfile, buf[0]) < 0) { | ||
1758 | BIO_printf(bio_err, "unable to rename %s to %s\n", | ||
1759 | dbfile, buf[0]); | ||
1760 | perror("reason"); | ||
1761 | } | ||
1762 | if (rename(buf[1], dbfile) < 0) { | ||
1763 | BIO_printf(bio_err, "unable to rename %s to %s\n", | ||
1764 | buf[1], dbfile); | ||
1765 | perror("reason"); | ||
1766 | } | ||
1739 | goto err; | 1767 | goto err; |
1740 | } | 1768 | } |
1741 | return 1; | 1769 | return 1; |