Codebase list openssl / 0f2e444
Make SRP_CTX.info ownership and lifetime be the same as SRP_CTX.login. Ownership and lifetime rules of SRP_CTX.info are confusing and different from those of SRP_CTX.login, making it difficult to use correctly. This makes the ownership and lifetime be the same as those of SRP_CTX.login, thet is a copy is made when setting it and is freed when SRP_CTX is freed. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3467) (cherry picked from commit e655f5494100d93307726b23f4718ead0cadc0c3) Diego Santa Cruz authored 7 years ago Matt Caswell committed 6 years ago
2 changed file(s) with 21 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
33833383 case SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD:
33843384 ctx->srp_ctx.SRP_give_srp_client_pwd_callback =
33853385 srp_password_from_info_cb;
3386 ctx->srp_ctx.info = parg;
3386 if (ctx->srp_ctx.info != NULL)
3387 OPENSSL_free(ctx->srp_ctx.info);
3388 if ((ctx->srp_ctx.info = BUF_strdup((char *)parg)) == NULL) {
3389 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_INTERNAL_ERROR);
3390 return 0;
3391 }
33873392 break;
33883393 case SSL_CTRL_SET_SRP_ARG:
33893394 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
1919 if (ctx == NULL)
2020 return 0;
2121 OPENSSL_free(ctx->srp_ctx.login);
22 OPENSSL_free(ctx->srp_ctx.info);
2223 BN_free(ctx->srp_ctx.N);
2324 BN_free(ctx->srp_ctx.g);
2425 BN_free(ctx->srp_ctx.s);
5152 if (s == NULL)
5253 return 0;
5354 OPENSSL_free(s->srp_ctx.login);
55 OPENSSL_free(s->srp_ctx.info);
5456 BN_free(s->srp_ctx.N);
5557 BN_free(s->srp_ctx.g);
5658 BN_free(s->srp_ctx.s);
104106 s->srp_ctx.b = NULL;
105107 s->srp_ctx.v = NULL;
106108 s->srp_ctx.login = NULL;
107 s->srp_ctx.info = ctx->srp_ctx.info;
109 s->srp_ctx.info = NULL;
108110 s->srp_ctx.strength = ctx->srp_ctx.strength;
109111
110112 if (((ctx->srp_ctx.N != NULL) &&
131133 SSLerr(SSL_F_SSL_SRP_CTX_INIT, ERR_R_INTERNAL_ERROR);
132134 goto err;
133135 }
136 if ((ctx->srp_ctx.info != NULL) &&
137 ((s->srp_ctx.info = BUF_strdup(ctx->srp_ctx.info)) == NULL)) {
138 SSLerr(SSL_F_SSL_SRP_CTX_INIT, ERR_R_INTERNAL_ERROR);
139 goto err;
140 }
134141 s->srp_ctx.srp_Mask = ctx->srp_ctx.srp_Mask;
135142
136143 return (1);
137144 err:
138145 OPENSSL_free(s->srp_ctx.login);
146 OPENSSL_free(s->srp_ctx.info);
139147 BN_free(s->srp_ctx.N);
140148 BN_free(s->srp_ctx.g);
141149 BN_free(s->srp_ctx.s);
271279 } else
272280 s->srp_ctx.v = BN_dup(v);
273281 }
274 s->srp_ctx.info = info;
282 if (info != NULL) {
283 if (s->srp_ctx.info)
284 OPENSSL_free(s->srp_ctx.info);
285 if ((s->srp_ctx.info = BUF_strdup(info)) == NULL)
286 return -1;
287 }
275288
276289 if (!(s->srp_ctx.N) ||
277290 !(s->srp_ctx.g) || !(s->srp_ctx.s) || !(s->srp_ctx.v))