Avoid freeing buffer offset
Related: RHEL-16450
This commit is contained in:
parent
9df0534fc4
commit
5c60a0f409
@ -438,3 +438,38 @@ index 66dfcdde67..7239b4c5b8 100644
|
|||||||
/* Debug virtual slots. S is slot to be highlighted or NULL
|
/* Debug virtual slots. S is slot to be highlighted or NULL
|
||||||
* C is a comment format string and args It will be preceded by "VSS " */
|
* C is a comment format string and args It will be preceded by "VSS " */
|
||||||
#define DEBUG_VSS(S, ...) do { sc_log(context,"VSS " __VA_ARGS__); _debug_virtual_slots(S); } while (0)
|
#define DEBUG_VSS(S, ...) do { sc_log(context,"VSS " __VA_ARGS__); _debug_virtual_slots(S); } while (0)
|
||||||
|
|
||||||
|
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