* util/grub-mkpasswd-pbkdf2.c (argp_parser): Remove unused variable.
(main): Likewise. Use xmalloc. Respect format security.
This commit is contained in:
parent
15b81d49bc
commit
a4d9fe4a95
2 changed files with 14 additions and 33 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2012-02-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* util/grub-mkpasswd-pbkdf2.c (argp_parser): Remove unused variable.
|
||||||
|
(main): Likewise. Use xmalloc. Respect format security.
|
||||||
|
|
||||||
2012-02-10 Vladimir Serbinenko <phcoder@gmail.com>
|
2012-02-10 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* util/grub-mklayout.c (console_grub_equivalence): Make "layout"
|
* util/grub-mklayout.c (console_grub_equivalence): Make "layout"
|
||||||
|
|
|
@ -57,8 +57,6 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
||||||
know is a pointer to our arguments structure. */
|
know is a pointer to our arguments structure. */
|
||||||
struct arguments *arguments = state->input;
|
struct arguments *arguments = state->input;
|
||||||
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 'c':
|
case 'c':
|
||||||
|
@ -117,7 +115,6 @@ main (int argc, char *argv[])
|
||||||
char *bufhex, *salthex, *result;
|
char *bufhex, *salthex, *result;
|
||||||
gcry_err_code_t gcry_err;
|
gcry_err_code_t gcry_err;
|
||||||
grub_uint8_t *buf, *salt;
|
grub_uint8_t *buf, *salt;
|
||||||
ssize_t nr;
|
|
||||||
char pass1[GRUB_AUTH_MAX_PASSLEN];
|
char pass1[GRUB_AUTH_MAX_PASSLEN];
|
||||||
char pass2[GRUB_AUTH_MAX_PASSLEN];
|
char pass2[GRUB_AUTH_MAX_PASSLEN];
|
||||||
|
|
||||||
|
@ -132,31 +129,10 @@ main (int argc, char *argv[])
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bufhex = malloc (arguments.buflen * 2 + 1);
|
bufhex = xmalloc (arguments.buflen * 2 + 1);
|
||||||
if (!bufhex)
|
buf = xmalloc (arguments.buflen);
|
||||||
grub_util_error (_("out of memory"));
|
salt = xmalloc (arguments.saltlen);
|
||||||
buf = malloc (arguments.buflen);
|
salthex = xmalloc (arguments.saltlen * 2 + 1);
|
||||||
if (!buf)
|
|
||||||
{
|
|
||||||
free (bufhex);
|
|
||||||
grub_util_error (_("out of memory"));
|
|
||||||
}
|
|
||||||
|
|
||||||
salt = malloc (arguments.saltlen);
|
|
||||||
if (!salt)
|
|
||||||
{
|
|
||||||
free (bufhex);
|
|
||||||
free (buf);
|
|
||||||
grub_util_error (_("out of memory"));
|
|
||||||
}
|
|
||||||
salthex = malloc (arguments.saltlen * 2 + 1);
|
|
||||||
if (!salthex)
|
|
||||||
{
|
|
||||||
free (salt);
|
|
||||||
free (bufhex);
|
|
||||||
free (buf);
|
|
||||||
grub_util_error (_("out of memory"));
|
|
||||||
}
|
|
||||||
|
|
||||||
printf ("%s", _("Enter password: "));
|
printf ("%s", _("Enter password: "));
|
||||||
if (!grub_password_get (pass1, GRUB_AUTH_MAX_PASSLEN))
|
if (!grub_password_get (pass1, GRUB_AUTH_MAX_PASSLEN))
|
||||||
|
@ -165,7 +141,7 @@ main (int argc, char *argv[])
|
||||||
free (bufhex);
|
free (bufhex);
|
||||||
free (salthex);
|
free (salthex);
|
||||||
free (salt);
|
free (salt);
|
||||||
grub_util_error (_("failure to read password"));
|
grub_util_error ("%s", _("failure to read password"));
|
||||||
}
|
}
|
||||||
printf ("\n%s", _("Reenter password: "));
|
printf ("\n%s", _("Reenter password: "));
|
||||||
if (!grub_password_get (pass2, GRUB_AUTH_MAX_PASSLEN))
|
if (!grub_password_get (pass2, GRUB_AUTH_MAX_PASSLEN))
|
||||||
|
@ -174,7 +150,7 @@ main (int argc, char *argv[])
|
||||||
free (bufhex);
|
free (bufhex);
|
||||||
free (salthex);
|
free (salthex);
|
||||||
free (salt);
|
free (salt);
|
||||||
grub_util_error (_("failure to read password"));
|
grub_util_error ("%s", _("failure to read password"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (pass1, pass2) != 0)
|
if (strcmp (pass1, pass2) != 0)
|
||||||
|
@ -185,7 +161,7 @@ main (int argc, char *argv[])
|
||||||
free (bufhex);
|
free (bufhex);
|
||||||
free (salthex);
|
free (salthex);
|
||||||
free (salt);
|
free (salt);
|
||||||
grub_util_error (_("passwords don't match"));
|
grub_util_error ("%s", _("passwords don't match"));
|
||||||
}
|
}
|
||||||
memset (pass2, 0, sizeof (pass2));
|
memset (pass2, 0, sizeof (pass2));
|
||||||
|
|
||||||
|
@ -205,7 +181,7 @@ main (int argc, char *argv[])
|
||||||
free (salthex);
|
free (salthex);
|
||||||
free (salt);
|
free (salt);
|
||||||
fclose (f);
|
fclose (f);
|
||||||
grub_util_error (_("couldn't retrieve random data for salt"));
|
grub_util_error ("%s", _("couldn't retrieve random data for salt"));
|
||||||
}
|
}
|
||||||
rd = fread (salt, 1, arguments.saltlen, f);
|
rd = fread (salt, 1, arguments.saltlen, f);
|
||||||
if (rd != arguments.saltlen)
|
if (rd != arguments.saltlen)
|
||||||
|
@ -216,7 +192,7 @@ main (int argc, char *argv[])
|
||||||
free (bufhex);
|
free (bufhex);
|
||||||
free (salthex);
|
free (salthex);
|
||||||
free (salt);
|
free (salt);
|
||||||
grub_util_error (_("couldn't retrieve random data for salt"));
|
grub_util_error ("%s", _("couldn't retrieve random data for salt"));
|
||||||
}
|
}
|
||||||
fclose (f);
|
fclose (f);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue