X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccore%2Fsilcauth.c;fp=lib%2Fsilccore%2Fsilcauth.c;h=73da54044d3124dc564c82252ad24bad4a05bc06;hb=8645fe960ed671b77cbf5688d03ce5576c3e38ea;hp=6e73a9f468bff84c7d84f0ee993e1bc32c613d22;hpb=190cb46e402c8d9f44157bb603c3af24af3e3bfa;p=silc.git diff --git a/lib/silccore/silcauth.c b/lib/silccore/silcauth.c index 6e73a9f4..73da5404 100644 --- a/lib/silccore/silcauth.c +++ b/lib/silccore/silcauth.c @@ -369,8 +369,17 @@ bool silc_auth_verify(SilcAuthPayload payload, SilcAuthMethod auth_method, case SILC_AUTH_PASSWORD: /* Passphrase based authentication. The `pkcs', `hash', `id' and `type' arguments are not needed. */ + /* Carefully check that the auth_data field of the payload is not empty + (len=0), which seems to be a legal packet but would crash the + application. Maybe such packet should be dropped. -Johnny 2002/14/4 */ + if ((payload->auth_len == 0) || !auth_data) + break; + + /* if lengths mismatch, avoid comparing unallocated memory locations */ + if (payload->auth_len != auth_data_len) + break; if (!memcmp(payload->auth_data, auth_data, auth_data_len)) { - SILC_LOG_DEBUG(("Authentication successful")); + SILC_LOG_DEBUG(("Passphrase Authentication successful")); return TRUE; } break;