From e6abffbca51c35f46911097def2a8ae03f450962 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 6 Mar 2021 17:59:36 +0100 Subject: Added more overflow sanitation logging --- libc/sanitize.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'libc') diff --git a/libc/sanitize.c b/libc/sanitize.c index 983b10f..8cfec49 100644 --- a/libc/sanitize.c +++ b/libc/sanitize.c @@ -97,28 +97,40 @@ void __ubsan_handle_vla_bound_not_positive(void) panic("UBSAN: vla-bound-not-positive\n"); } -void __ubsan_handle_add_overflow(void); -void __ubsan_handle_add_overflow(void) +void __ubsan_handle_add_overflow(struct overflow *data, void *left, void *right); +void __ubsan_handle_add_overflow(struct overflow *data, void *left, void *right) { - panic("UBSAN: add-overflow\n"); + UNUSED(left); + UNUSED(right); + struct source_location *loc = &data->location; + panic("%s:%d: UBSAN: add-overflow [type: %s]\n", loc->file, loc->line, data->type->name); } -void __ubsan_handle_sub_overflow(void); -void __ubsan_handle_sub_overflow(void) +void __ubsan_handle_sub_overflow(struct overflow *data, void *left, void *right); +void __ubsan_handle_sub_overflow(struct overflow *data, void *left, void *right) { - panic("UBSAN: sub-overflow\n"); + UNUSED(left); + UNUSED(right); + struct source_location *loc = &data->location; + panic("%s:%d: UBSAN: sub-overflow [type: %s]\n", loc->file, loc->line, data->type->name); } -void __ubsan_handle_negate_overflow(void); -void __ubsan_handle_negate_overflow(void) +void __ubsan_handle_negate_overflow(struct overflow *data, void *left, void *right); +void __ubsan_handle_negate_overflow(struct overflow *data, void *left, void *right) { - panic("UBSAN: negate-overflow\n"); + UNUSED(left); + UNUSED(right); + struct source_location *loc = &data->location; + panic("%s:%d: UBSAN: negate-overflow [type: %s]\n", loc->file, loc->line, data->type->name); } -void __ubsan_handle_mul_overflow(void); -void __ubsan_handle_mul_overflow(void) +void __ubsan_handle_mul_overflow(struct overflow *data, void *left, void *right); +void __ubsan_handle_mul_overflow(struct overflow *data, void *left, void *right) { - panic("UBSAN: mul-overflow\n"); + UNUSED(left); + UNUSED(right); + struct source_location *loc = &data->location; + panic("%s:%d: UBSAN: mul-overflow [type: %s]\n", loc->file, loc->line, data->type->name); } void __ubsan_handle_shift_out_of_bounds(void); -- cgit v1.2.3