From 30b3264e60aea7c0b5d6578f6bb87087fd99ff05 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 21 Mar 2019 20:08:45 -0700 Subject: [PATCH] drd: Fix an integer overflow in the stack margin calculation --- NEWS | 1 + drd/drd_main.c | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index c9431a2a39..a460d8eae5 100644 --- a/NEWS +++ b/NEWS @@ -112,6 +112,7 @@ where XXXXXX is the bug number as listed below. 405079 unhandled ppc64le-linux syscall: 131 (quotactl) 405403 s390x disassembler cannot be used on x86 405458 MIPS mkFormVEC arguments swapped? +405716 drd: Fix an integer overflow in the stack margin calculation n-i-bz add syswrap for PTRACE_GET|SET_THREAD_AREA on amd64. n-i-bz Fix callgrind_annotate non deterministic order for equal total diff --git a/drd/drd_main.c b/drd/drd_main.c index 3df967ef28..6d6ca637dc 100644 --- a/drd/drd_main.c +++ b/drd/drd_main.c @@ -705,12 +705,11 @@ static void drd_thread_finished(ThreadId vg_tid) = (DRD_(thread_get_stack_max)(drd_tid) - DRD_(thread_get_stack_min_min)(drd_tid)); VG_(message)(Vg_UserMsg, - "thread %u%s finished and used %lu bytes out of %lu" - " on its stack. Margin: %lu bytes.\n", + "thread %u%s finished and used %lu bytes out of %lu on its stack. Margin: %ld bytes.\n", drd_tid, DRD_(thread_get_joinable)(drd_tid) ? "" : " (which is a detached thread)", - used_stack, stack_size, stack_size - used_stack); + used_stack, stack_size, (long)(stack_size - used_stack)); } drd_stop_using_mem(DRD_(thread_get_stack_min)(drd_tid), -- 2.47.2