Skip to content

Commit

Permalink
Merge pull request #128 from technion/inlength
Browse files Browse the repository at this point in the history
Improve handling of long passwords for command line utility.
  • Loading branch information
daniel-dinu committed Apr 6, 2016
2 parents cd77d12 + 5d2810e commit 6bf7eea
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define LANES_DEF 1
#define THREADS_DEF 1
#define OUTLEN_DEF 32
#define MAX_PASS_LEN 128

#define UNUSED_PARAMETER(x) (void)(x)

Expand Down Expand Up @@ -161,18 +162,25 @@ int main(int argc, char *argv[]) {
int raw_only = 0;
int i;
size_t n;
char pwd[128], *salt;
char pwd[MAX_PASS_LEN], *salt;

if (argc < 2) {
usage(argv[0]);
return ARGON2_MISSING_ARGS;
}

/* get password from stdin */
while ((n = fread(pwd, 1, sizeof pwd - 1, stdin)) > 0) {
pwd[n] = '\0';
if (pwd[n - 1] == '\n')
pwd[n - 1] = '\0';
n = fread(pwd, 1, sizeof pwd - 1, stdin);
if(n < 1) {
fatal("no password read");
}
if(n == MAX_PASS_LEN-1) {
fatal("Provided password longer than supported in command line utility");
}

pwd[n] = '\0';
if (pwd[n - 1] == '\n') {
pwd[n - 1] = '\0';
}

salt = argv[1];
Expand Down

0 comments on commit 6bf7eea

Please sign in to comment.