mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/5] login: check return value of digest_alloc
Date: Thu, 27 Aug 2015 17:26:12 +0200	[thread overview]
Message-ID: <1440689174-731-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1440689174-731-1-git-send-email-s.hauer@pengutronix.de>

digest_alloc can fail, check the return value.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/password.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/common/password.c b/common/password.c
index 0cb79b8..43c5e0c 100644
--- a/common/password.c
+++ b/common/password.c
@@ -288,6 +288,10 @@ static int check_passwd(unsigned char *passwd, size_t length)
 		hash_len = PBKDF2_LENGTH;
 	} else {
 		d = digest_alloc(PASSWD_SUM);
+		if (!d) {
+			pr_err("No such digest: %s\n", PASSWD_SUM);
+			return -ENOENT;
+		}
 
 		hash_len = digest_length(d);
 	}
-- 
2.5.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-08-27 15:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-27 15:26 [PATCH 1/5] login: rework login mechanism Sascha Hauer
2015-08-27 15:26 ` [PATCH 2/5] login: cleanup password code Sascha Hauer
2015-08-27 15:26 ` Sascha Hauer [this message]
2015-08-27 15:26 ` [PATCH 4/5] crypto: fix selecting of digests Sascha Hauer
2015-08-27 15:26 ` [PATCH 5/5] login: explain PASSWORD_DEFAULT option Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440689174-731-3-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox