mirror of
https://github.com/ceph/ceph
synced 2025-02-24 19:47:44 +00:00
secret.c: use safe_read when appropriate
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
This commit is contained in:
parent
9e4adf0de9
commit
b2c803db33
@ -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
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user