mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 03:40:05 +01:00
Add some checks for error codes.
(fixes warning: ignoring return value ...) git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@59 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
15
lib/setup.c
15
lib/setup.c
@@ -28,10 +28,11 @@ static char *default_backend = NULL;
|
|||||||
|
|
||||||
static void logger(struct crypt_options *options, int class, char *format, ...) {
|
static void logger(struct crypt_options *options, int class, char *format, ...) {
|
||||||
va_list argp;
|
va_list argp;
|
||||||
char *target;
|
char *target = NULL;
|
||||||
|
|
||||||
va_start(argp, format);
|
va_start(argp, format);
|
||||||
vasprintf(&target, format, argp);
|
|
||||||
|
if (vasprintf(&target, format, argp) > 0)
|
||||||
options->icb->log(class, target);
|
options->icb->log(class, target);
|
||||||
|
|
||||||
va_end(argp);
|
va_end(argp);
|
||||||
@@ -342,8 +343,8 @@ static int __crypt_create_device(int reload, struct setup_backend *backend,
|
|||||||
if (!processed_key) {
|
if (!processed_key) {
|
||||||
const char *error=get_error();
|
const char *error=get_error();
|
||||||
if(error) {
|
if(error) {
|
||||||
char *c_error_handling_sucks;
|
char *c_error_handling_sucks = NULL;
|
||||||
asprintf(&c_error_handling_sucks,"Key processing error: %s",error);
|
if (asprintf(&c_error_handling_sucks,"Key processing error: %s",error) > 0)
|
||||||
set_error(c_error_handling_sucks);
|
set_error(c_error_handling_sucks);
|
||||||
free(c_error_handling_sucks);
|
free(c_error_handling_sucks);
|
||||||
} else
|
} else
|
||||||
@@ -514,7 +515,7 @@ static int __crypt_luks_open(int arg, struct setup_backend *backend, struct cryp
|
|||||||
struct crypt_options tmp = {
|
struct crypt_options tmp = {
|
||||||
.name = options->name,
|
.name = options->name,
|
||||||
};
|
};
|
||||||
char *dmCipherSpec;
|
char *dmCipherSpec = NULL;
|
||||||
int r, tries = options->tries;
|
int r, tries = options->tries;
|
||||||
int excl = (options->flags & CRYPT_FLAG_NON_EXCLUSIVE_ACCESS) ? 0 : O_EXCL ;
|
int excl = (options->flags & CRYPT_FLAG_NON_EXCLUSIVE_ACCESS) ? 0 : O_EXCL ;
|
||||||
|
|
||||||
@@ -560,8 +561,7 @@ start:
|
|||||||
|
|
||||||
|
|
||||||
options->offset = hdr.payloadOffset;
|
options->offset = hdr.payloadOffset;
|
||||||
asprintf(&dmCipherSpec, "%s-%s", hdr.cipherName, hdr.cipherMode);
|
if (asprintf(&dmCipherSpec, "%s-%s", hdr.cipherName, hdr.cipherMode) < 0) {
|
||||||
if(!dmCipherSpec) {
|
|
||||||
r = -ENOMEM;
|
r = -ENOMEM;
|
||||||
goto out2;
|
goto out2;
|
||||||
}
|
}
|
||||||
@@ -585,6 +585,7 @@ start:
|
|||||||
|
|
||||||
out2:
|
out2:
|
||||||
free(dmCipherSpec);
|
free(dmCipherSpec);
|
||||||
|
dmCipherSpec = NULL;
|
||||||
out1:
|
out1:
|
||||||
safe_free(password);
|
safe_free(password);
|
||||||
out:
|
out:
|
||||||
|
|||||||
11
lib/utils.c
11
lib/utils.c
@@ -34,7 +34,10 @@ void set_error_va(const char *fmt, va_list va)
|
|||||||
|
|
||||||
if(!fmt) return;
|
if(!fmt) return;
|
||||||
|
|
||||||
vasprintf(&error, fmt, va);
|
if (vasprintf(&error, fmt, va) < 0) {
|
||||||
|
free(error);
|
||||||
|
error = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error(const char *fmt, ...)
|
void set_error(const char *fmt, ...)
|
||||||
@@ -314,7 +317,9 @@ static int interactive_pass(const char *prompt, char *pass, size_t maxlen,
|
|||||||
memcpy(&tmp, &orig, sizeof(tmp));
|
memcpy(&tmp, &orig, sizeof(tmp));
|
||||||
tmp.c_lflag &= ~ECHO;
|
tmp.c_lflag &= ~ECHO;
|
||||||
|
|
||||||
write(outfd, prompt, strlen(prompt));
|
if (write(outfd, prompt, strlen(prompt)) < 0)
|
||||||
|
goto out_err;
|
||||||
|
|
||||||
tcsetattr(infd, TCSAFLUSH, &tmp);
|
tcsetattr(infd, TCSAFLUSH, &tmp);
|
||||||
if (timeout)
|
if (timeout)
|
||||||
failed = timed_read(infd, pass, maxlen, timeout);
|
failed = timed_read(infd, pass, maxlen, timeout);
|
||||||
@@ -324,7 +329,7 @@ static int interactive_pass(const char *prompt, char *pass, size_t maxlen,
|
|||||||
|
|
||||||
out_err:
|
out_err:
|
||||||
if (!failed)
|
if (!failed)
|
||||||
write(outfd, "\n", 1);
|
(void)write(outfd, "\n", 1);
|
||||||
if (infd != STDIN_FILENO)
|
if (infd != STDIN_FILENO)
|
||||||
close(infd);
|
close(infd);
|
||||||
return failed;
|
return failed;
|
||||||
|
|||||||
Reference in New Issue
Block a user