Fix SASL SCRAM implementation

* Add SCRAM_DIGEST_SIZE macro for maximum possible digest size. It will
  avoid new buffer overflow errors when new digests are added.
* Fix buffer overflow in sasl_scram(). Buffers were allocated for SHA1
  digest size.
* Fix bug with handler re-registration when a SASL SCRAM mechanism
  fails.
This commit is contained in:
Dmitry Podgorny
2020-01-05 18:46:15 +02:00
parent 709e41fd10
commit 1ca10fd167
4 changed files with 38 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/* scram.h
* strophe XMPP client library -- SCRAM-SHA1 helper functions
* strophe XMPP client library -- SCRAM helper functions
*
* Copyright (C) 2013 Dmitry Podgorny <pasis.ua@gmail.com>
*
@@ -10,7 +10,7 @@
*/
/** @file
* SCRAM-SHA1 helper functions.
* SCRAM helper functions.
*/
#ifndef __LIBSTROPHE_SCRAM_H__
@@ -19,6 +19,10 @@
/* make sure the stdint.h types are available */
#include "ostypes.h"
/* Maximum possible digest size. Used for buffers allocation. */
#include "sha512.h"
#define SCRAM_DIGEST_SIZE SHA512_DIGEST_SIZE
struct hash_alg {
const char *scram_name;
int mask;