X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Futil%2Fsrp.cpp;h=d825f0ebc24e65494045f3ac99568dea27e96023;hb=84a5fa01fff2b81fae12411c31502a49f152ed1d;hp=0d3c938a3a593bb6a244e57ba429153e8e1f2937;hpb=9a04dfd0f5a69f60318a243535993ffa234f6bf6;p=minetest.git diff --git a/src/util/srp.cpp b/src/util/srp.cpp index 0d3c938a3..d825f0ebc 100644 --- a/src/util/srp.cpp +++ b/src/util/srp.cpp @@ -27,24 +27,29 @@ */ // clang-format off + +#include + #ifdef WIN32 #include #include #else - #include + #include + #endif // clang-format on -#include -#include -#include +#include +#include +#include +#include #include #if USE_SYSTEM_GMP || defined (__ANDROID__) || defined (ANDROID) #include #else - #include + #include #endif #include @@ -417,7 +422,7 @@ static SRP_Result H_nn( } static SRP_Result H_ns(mpz_t result, SRP_HashAlgorithm alg, const unsigned char *n, - size_t len_n, const unsigned char *bytes, size_t len_bytes) + size_t len_n, const unsigned char *bytes, uint32_t len_bytes) { unsigned char buff[SHA512_DIGEST_LENGTH]; size_t nbytes = len_n + len_bytes; @@ -542,7 +547,7 @@ static SRP_Result fill_buff() if (!fp) return SRP_ERR; - if (fread(g_rand_buff, sizeof(g_rand_buff), 1, fp) != 1) return SRP_ERR; + if (fread(g_rand_buff, sizeof(g_rand_buff), 1, fp) != 1) { fclose(fp); return SRP_ERR; } if (fclose(fp)) return SRP_ERR; #endif return SRP_OK; @@ -611,7 +616,7 @@ SRP_Result srp_create_salted_verification_key( SRP_HashAlgorithm alg, if (fill_buff() != SRP_OK) goto error_and_exit; *bytes_s = (unsigned char *)srp_alloc(size_to_fill); if (!*bytes_s) goto error_and_exit; - memcpy(*bytes_s, &g_rand_buff + g_rand_idx, size_to_fill); + memcpy(*bytes_s, &g_rand_buff[g_rand_idx], size_to_fill); g_rand_idx += size_to_fill; } @@ -696,7 +701,7 @@ struct SRPVerifier *srp_verifier_new(SRP_HashAlgorithm alg, goto cleanup_and_exit; } - memcpy((char *)ver->username, username, ulen); + memcpy(ver->username, username, ulen); ver->authenticated = 0; @@ -861,7 +866,7 @@ struct SRPUser *srp_user_new(SRP_HashAlgorithm alg, SRP_NGType ng_type, mpz_clear(usr->a); mpz_clear(usr->A); mpz_clear(usr->S); - if (usr->ng) delete_ng(usr->ng); + delete_ng(usr->ng); srp_free(usr->username); srp_free(usr->username_verifier); if (usr->password) {