Avoid freeing buffer offset
Related: RHEL-17087
This commit is contained in:
parent
348c4e3f40
commit
0766703007
@ -381,3 +381,37 @@ index f04c0b4c5..93cc319c2 100644
|
|||||||
sc_pkcs11_unlock();
|
sc_pkcs11_unlock();
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diff --git a/src/libopensc/padding.c b/src/libopensc/padding.c
|
||||||
|
index ceb2a1e21..c2cc58d47 100644
|
||||||
|
--- a/src/libopensc/padding.c
|
||||||
|
+++ b/src/libopensc/padding.c
|
||||||
|
@@ -192,7 +192,7 @@ int
|
||||||
|
sc_pkcs1_strip_02_padding_constant_time(sc_context_t *ctx, unsigned int n, const u8 *data, unsigned int data_len, u8 *out, unsigned int *out_len)
|
||||||
|
{
|
||||||
|
unsigned int i = 0;
|
||||||
|
- u8 *msg = NULL;
|
||||||
|
+ u8 *msg, *msg_orig = NULL;
|
||||||
|
unsigned int good, found_zero_byte, mask;
|
||||||
|
unsigned int zero_index = 0, msg_index, mlen = -1, len = 0;
|
||||||
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
@@ -200,7 +200,7 @@ sc_pkcs1_strip_02_padding_constant_time(sc_context_t *ctx, unsigned int n, const
|
||||||
|
if (data == NULL || data_len <= 0 || data_len > n || n < SC_PKCS1_PADDING_MIN_SIZE)
|
||||||
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
|
||||||
|
|
||||||
|
- msg = calloc(n, sizeof(u8));
|
||||||
|
+ msg = msg_orig = calloc(n, sizeof(u8));
|
||||||
|
if (msg == NULL)
|
||||||
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
|
||||||
|
|
||||||
|
@@ -261,7 +261,7 @@ sc_pkcs1_strip_02_padding_constant_time(sc_context_t *ctx, unsigned int n, const
|
||||||
|
out[i] = constant_time_select_8(mask, msg[msg_index], out[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- free(msg);
|
||||||
|
+ free(msg_orig);
|
||||||
|
return constant_time_select(good, mlen, SC_ERROR_WRONG_PADDING);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.43.0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user