c20b5e0a0ef9defe921f569a39b2b2a01c1839a5
[gentoo.git] / mail-mta / opensmtpd / files / opensmtpd-6.0.3_p1-fix-crash-on-auth.patch
1 From 9b5f70b93e038df5446bd37a4adac5a0380748e7 Mon Sep 17 00:00:00 2001
2 From: johannes <johannes.brechtmann@gmail.com>
3 Date: Wed, 21 Feb 2018 23:57:11 +0100
4 Subject: [PATCH] crypt_checkpass: include HAVE_CRYPT_H definition, add NULL
5  check
6
7 ---
8  openbsd-compat/crypt_checkpass.c | 9 ++++++++-
9  1 file changed, 8 insertions(+), 1 deletion(-)
10
11 diff --git a/openbsd-compat/crypt_checkpass.c b/openbsd-compat/crypt_checkpass.c
12 index dafd2dae..d10b3a57 100644
13 --- a/openbsd-compat/crypt_checkpass.c
14 +++ b/openbsd-compat/crypt_checkpass.c
15 @@ -1,5 +1,6 @@
16  /* OPENBSD ORIGINAL: lib/libc/crypt/cryptutil.c */
17  
18 +#include "includes.h"
19  #include <errno.h>
20  #ifdef HAVE_CRYPT_H
21  #include <crypt.h>
22 @@ -10,6 +11,8 @@
23  int
24  crypt_checkpass(const char *pass, const char *goodhash)
25  {
26 +       char *c;
27 +
28         if (goodhash == NULL)
29                 goto fail;
30  
31 @@ -17,7 +20,11 @@ crypt_checkpass(const char *pass, const char *goodhash)
32         if (strlen(goodhash) == 0 && strlen(pass) == 0)
33                 return 0;
34  
35 -       if (strcmp(crypt(pass, goodhash), goodhash) == 0)
36 +       c = crypt(pass, goodhash);
37 +       if (c == NULL)
38 +               goto fail;
39 +
40 +       if (strcmp(c, goodhash) == 0)
41                 return 0;
42  
43  fail: