Print error when getline() fails (thanks to Ivan Stankovic)

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@76 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
Milan Broz
2009-07-30 14:46:56 +00:00
parent f60475e293
commit 4a257d8c65
2 changed files with 15 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
2009-07-30 Milan Broz <mbroz@redhat.com> 2009-07-30 Milan Broz <mbroz@redhat.com>
* Fix errors when compiled with LUKS_DEBUG. * Fix errors when compiled with LUKS_DEBUG.
* Print error when getline fails.
2009-07-28 Milan Broz <mbroz@redhat.com> 2009-07-28 Milan Broz <mbroz@redhat.com>
* Pad luks header to 512 sector size. * Pad luks header to 512 sector size.

View File

@@ -79,19 +79,23 @@ static struct action_type {
/* Interface Callbacks */ /* Interface Callbacks */
static int yesDialog(char *msg) static int yesDialog(char *msg)
{ {
int r = 0; char *answer = NULL;
size_t size = 0;
int r = 1;
if(isatty(0) && !opt_batch_mode) { if(isatty(0) && !opt_batch_mode) {
char *answer=NULL; fprintf(stderr, "\nWARNING!\n========\n");
size_t size=0; fprintf(stderr, "%s\n\nAre you sure? (Type uppercase yes): ", msg);
fprintf(stderr,"\nWARNING!\n========\n"); if(getline(&answer, &size, stdin) == -1) {
fprintf(stderr,"%s\n\nAre you sure? (Type uppercase yes): ",msg); perror("getline");
if(getline(&answer,&size,stdin) == -1) free(answer);
return 0; return 0;
if(strcmp(answer,"YES\n") == 0) }
r = 1; if(strcmp(answer, "YES\n"))
r = 0;
free(answer); free(answer);
} else }
r = 1;
return r; return r;
} }