112-CVE-2018-1000121.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From 8f341a5d6f15381492ca2013325d485b6d8d1c13 Mon Sep 17 00:00:00 2001
  2. From: Daniel Stenberg <daniel@haxx.se>
  3. Date: Tue, 6 Mar 2018 23:02:16 +0100
  4. Subject: [PATCH] openldap: check ldap_get_attribute_ber() results for NULL
  5. before using
  6. CVE-2018-1000121
  7. Reported-by: Dario Weisser
  8. Bug: https://curl.haxx.se/docs/adv_2018-97a2.html
  9. ---
  10. lib/openldap.c | 8 ++++----
  11. 1 file changed, 4 insertions(+), 4 deletions(-)
  12. --- a/lib/openldap.c
  13. +++ b/lib/openldap.c
  14. @@ -443,7 +443,7 @@ static ssize_t ldap_recv(struct connectd
  15. for(ent = ldap_first_message(li->ld, msg); ent;
  16. ent = ldap_next_message(li->ld, ent)) {
  17. - struct berval bv, *bvals, **bvp = &bvals;
  18. + struct berval bv, *bvals;
  19. int binary = 0, msgtype;
  20. CURLcode writeerr;
  21. @@ -505,9 +505,9 @@ static ssize_t ldap_recv(struct connectd
  22. }
  23. data->req.bytecount += bv.bv_len + 5;
  24. - for(rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp);
  25. - rc == LDAP_SUCCESS;
  26. - rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp)) {
  27. + for(rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, &bvals);
  28. + (rc == LDAP_SUCCESS) && bvals;
  29. + rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, &bvals)) {
  30. int i;
  31. if(bv.bv_val == NULL) break;