secret.c: use safe_read when appropriate

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
This commit is contained in:
Colin Patrick McCabe 2011-06-17 10:18:32 -07:00
parent 9e4adf0de9
commit b2c803db33
3 changed files with 4 additions and 3 deletions

View File

@ -94,7 +94,7 @@ osdmaptool_SOURCES = osdmaptool.cc
osdmaptool_LDADD = libcommon.a -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS)
bin_PROGRAMS += monmaptool crushtool osdmaptool
mount_ceph_SOURCES = mount/mount.ceph.c common/armor.c common/secret.c include/addr_parsing.c
mount_ceph_SOURCES = mount/mount.ceph.c common/armor.c common/safe_io.c common/secret.c include/addr_parsing.c
mount_ceph_LDADD = -lkeyutils
sbin_PROGRAMS += mount.ceph

View File

@ -23,7 +23,7 @@ extern "C" {
/*
* Safe functions wrapping the raw read() and write() libc functions.
* These retry on EINTR, and on error return -errno instead of returning
* 1 and setting errno).
* -1 and setting errno).
*/
ssize_t safe_read(int fd, void *buf, size_t count)
__attribute__ ((warn_unused_result));

View File

@ -22,6 +22,7 @@
#include <sys/types.h>
#include "common/armor.h"
#include "common/safe_io.h"
int read_secret_from_file(const char *filename, char *secret, size_t max_len)
{
@ -34,7 +35,7 @@ int read_secret_from_file(const char *filename, char *secret, size_t max_len)
perror("unable to read secretfile");
return -1;
}
len = read(fd, secret, max_len);
len = safe_read(fd, secret, max_len);
if (len <= 0) {
perror("unable to read secret from file");
return -1;