{"id":808149,"url":"http://patchwork.ozlabs.org/api/patches/808149/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/patch/20170831100511.8D77F43994318@oldenburg.str.redhat.com/","project":{"id":41,"url":"http://patchwork.ozlabs.org/api/projects/41/?format=json","name":"GNU C Library","link_name":"glibc","list_id":"libc-alpha.sourceware.org","list_email":"libc-alpha@sourceware.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170831100511.8D77F43994318@oldenburg.str.redhat.com>","list_archive_url":null,"date":"2017-08-31T10:05:11","name":"malloc: Change top_check return type to void","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"de3167dace5b57381da8501ac092b08f50f4eca9","submitter":{"id":14312,"url":"http://patchwork.ozlabs.org/api/people/14312/?format=json","name":"Florian Weimer","email":"fweimer@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/glibc/patch/20170831100511.8D77F43994318@oldenburg.str.redhat.com/mbox/","series":[{"id":781,"url":"http://patchwork.ozlabs.org/api/series/781/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/list/?series=781","date":"2017-08-31T10:05:11","name":"malloc: Change top_check return type to void","version":1,"mbox":"http://patchwork.ozlabs.org/series/781/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/808149/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808149/checks/","tags":{},"related":[],"headers":{"Return-Path":"<libc-alpha-return-83903-incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list libc-alpha@sourceware.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-83903-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"H/SU+m8p\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=fweimer@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjdKk5p49z9sPm\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 20:05:30 +1000 (AEST)","(qmail 58981 invoked by alias); 31 Aug 2017 10:05:24 -0000","(qmail 58963 invoked by uid 89); 31 Aug 2017 10:05:24 -0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:date:to:subject:mime-version:content-type\n\t:content-transfer-encoding:message-id:from; q=dns; s=default; b=\n\tvbcW7uySgi7t8CwXKUNee+8IPT6aeEs3/SxwntpPOgDJEfLjJ9snLtaHnNLezzlL\n\t/vR3UpAC4fdcccKhoo65fF6enNMszkT/7icb7RPQDyLWF23GzQWr1zZxhx+8065Z\n\tdzWykr8ixUJIxpqSW5GYig+UsNyaiRhgjr3s/u6GwVM=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:date:to:subject:mime-version:content-type\n\t:content-transfer-encoding:message-id:from; s=default; bh=Xxs565\n\tqudowWgjz4fdgs7B/8yeE=; b=H/SU+m8pDCzQbG0fFmBsYhhW+L4kUmCPchXS52\n\tofOFMmpCcGr/zLRC3VkYh5cJ/TwSQVG2WtZBLxKQyQgFkn1OwXLHRfQ7ZEE61GJf\n\teFgEWdji2u7fnkmUYqCBMC8S0Pb4GHVxBF2Q8k0KoMTN7YtOgqafmrh7CV1MS6ro\n\ty+EGA=","Mailing-List":"contact libc-alpha-help@sourceware.org; run by ezmlm","Precedence":"bulk","List-Id":"<libc-alpha.sourceware.org>","List-Unsubscribe":"<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>","List-Subscribe":"<mailto:libc-alpha-subscribe@sourceware.org>","List-Archive":"<http://sourceware.org/ml/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>","Sender":"libc-alpha-owner@sourceware.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com AA6D37F6AC","Date":"Thu, 31 Aug 2017 12:05:11 +0200","To":"libc-alpha@sourceware.org","Subject":"[PATCH] malloc: Change top_check return type to void","User-Agent":"Heirloom mailx 12.5 7/5/10","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Transfer-Encoding":"7bit","Message-Id":"<20170831100511.8D77F43994318@oldenburg.str.redhat.com>","From":"fweimer@redhat.com (Florian Weimer)"},"content":"After commit ec2c1fcefb200c6cb7e09553f3c6af8815013d83,\n(malloc: Abort on heap corruption, without a backtrace), the function\nalways returns 0.\n\n2017-08-31  Florian Weimer  <fweimer@redhat.com>\n\n\t* malloc/malloc.c (top_check): Change return type to void.  Remove\n\tinternal_function.\n\t* malloc/hooks.c (top_check): Likewise.\n\t(malloc_check, realloc_check, memalign_check): Adjust.","diff":"diff --git a/malloc/hooks.c b/malloc/hooks.c\nindex dcd311e7c7..4398c0a017 100644\n--- a/malloc/hooks.c\n+++ b/malloc/hooks.c\n@@ -228,8 +228,7 @@ mem2chunk_check (void *mem, unsigned char **magic_p)\n }\n \n /* Check for corruption of the top chunk.  */\n-static int\n-internal_function\n+static void\n top_check (void)\n {\n   mchunkptr t = top (&main_arena);\n@@ -240,7 +239,7 @@ top_check (void)\n        prev_inuse (t) &&\n        (!contiguous (&main_arena) ||\n         (char *) t + chunksize (t) == mp_.sbrk_base + main_arena.system_mem)))\n-    return 0;\n+    return;\n \n   malloc_printerr (\"malloc: top chunk is corrupt\");\n }\n@@ -257,7 +256,8 @@ malloc_check (size_t sz, const void *caller)\n     }\n \n   __libc_lock_lock (main_arena.mutex);\n-  victim = (top_check () >= 0) ? _int_malloc (&main_arena, sz + 1) : NULL;\n+  top_check ();\n+  victim = _int_malloc (&main_arena, sz + 1);\n   __libc_lock_unlock (main_arena.mutex);\n   return mem2mem_check (victim, sz);\n }\n@@ -329,8 +329,8 @@ realloc_check (void *oldmem, size_t bytes, const void *caller)\n         else\n           {\n             /* Must alloc, copy, free. */\n-            if (top_check () >= 0)\n-              newmem = _int_malloc (&main_arena, bytes + 1);\n+\t    top_check ();\n+\t    newmem = _int_malloc (&main_arena, bytes + 1);\n             if (newmem)\n               {\n                 memcpy (newmem, oldmem, oldsize - 2 * SIZE_SZ);\n@@ -341,12 +341,10 @@ realloc_check (void *oldmem, size_t bytes, const void *caller)\n     }\n   else\n     {\n-      if (top_check () >= 0)\n-        {\n-          INTERNAL_SIZE_T nb;\n-          checked_request2size (bytes + 1, nb);\n-          newmem = _int_realloc (&main_arena, oldp, oldsize, nb);\n-        }\n+      top_check ();\n+      INTERNAL_SIZE_T nb;\n+      checked_request2size (bytes + 1, nb);\n+      newmem = _int_realloc (&main_arena, oldp, oldsize, nb);\n     }\n \n   /* mem2chunk_check changed the magic byte in the old chunk.\n@@ -396,8 +394,8 @@ memalign_check (size_t alignment, size_t bytes, const void *caller)\n     }\n \n   __libc_lock_lock (main_arena.mutex);\n-  mem = (top_check () >= 0) ? _int_memalign (&main_arena, alignment, bytes + 1) :\n-        NULL;\n+  top_check ();\n+  mem = _int_memalign (&main_arena, alignment, bytes + 1);\n   __libc_lock_unlock (main_arena.mutex);\n   return mem2mem_check (mem, bytes);\n }\ndiff --git a/malloc/malloc.c b/malloc/malloc.c\nindex 65bbf02cb7..768670ccf6 100644\n--- a/malloc/malloc.c\n+++ b/malloc/malloc.c\n@@ -1022,7 +1022,7 @@ static void*  _mid_memalign(size_t, size_t, void *);\n static void malloc_printerr(const char *str) __attribute__ ((noreturn));\n \n static void* internal_function mem2mem_check(void *p, size_t sz);\n-static int internal_function top_check(void);\n+static void top_check (void);\n static void internal_function munmap_chunk(mchunkptr p);\n #if HAVE_MREMAP\n static mchunkptr internal_function mremap_chunk(mchunkptr p, size_t new_size);\n","prefixes":[]}