From patchwork Mon Aug 27 18:12:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Pluzhnikov X-Patchwork-Id: 29077 Received: (qmail 7366 invoked by alias); 27 Aug 2018 18:13:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 7253 invoked by uid 89); 27 Aug 2018 18:13:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-33.1 required=5.0 tests=AWL, BAYES_00, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS, USER_IN_DEF_SPF_WL autolearn=ham version=3.3.2 spammy= X-HELO: mail-yb0-f172.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=kngKRSjNVmymox0LA9ZA80kMWqZ8buLwv74dOJXY3o8=; b=YGeDzDiylMR8pEWhi6UyK5Px5W8xXsYYfH13+VbvPle0GWToYJET/pdmzcg8diIsjm Hs7sSdgMRjV0pV/ZCScve3K3522lwKrJB6r9VTAIf6MSQGX7ieso0skauHiku32mA0sx UWp+Mkr4qDh3kpz7qBlNx0omuw1rJiOnVHonXv/clgQ8y9VJzC53yGMfgpTJvR9ljfOC uE0NZI4XZzVt3N3FuQhItbFH8k+bvM8msZ2y1KW67iTP3ta4cTmQ10RE7aTyry/rEeRV eBy0gl6RA2ujl7hZ/i9rPfdnjLjiiyAcftKxgFk0UqlDCZ8bEUgxbtLOwZB7VRTjPiCw OaWw== MIME-Version: 1.0 From: Paul Pluzhnikov Date: Mon, 27 Aug 2018 11:12:46 -0700 Message-ID: Subject: [patch] Fix BZ#20544 (assert function passed to atexit/on_exit/__cxa_atexit != NULL) To: GLIBC Devel Greetings, As discussed in bz#20544 and in http://sourceware.org/glibc/wiki/Style_and_Conventions#Invalid_pointers, we should assert that the function passed to atexit, on_exit, etc. is not NULL. 2018-08-27 Paul Pluzhnikov [BZ #20544] * stdlib/cxa_atexit.c (__internal_atexit): assert func != NULL. * stdlib/on_exit.c (__on_exit): Likewise. diff --git a/stdlib/cxa_atexit.c b/stdlib/cxa_atexit.c index 6d65f7e615..978f873990 100644 --- a/stdlib/cxa_atexit.c +++ b/stdlib/cxa_atexit.c @@ -36,6 +36,9 @@ __internal_atexit (void (*func) (void *), void *arg, void *d, { struct exit_function *new; + /* BZ#20544 */ + assert (func != NULL); + __libc_lock_lock (__exit_funcs_lock); new = __new_exitfn (listp); diff --git a/stdlib/on_exit.c b/stdlib/on_exit.c index 5241e0d86f..0ead1eafd4 100644 --- a/stdlib/on_exit.c +++ b/stdlib/on_exit.c @@ -15,6 +15,7 @@ License along with the GNU C Library; if not, see . */ +#include #include #include "exit.h" #include @@ -25,6 +26,9 @@ __on_exit (void (*func) (int status, void *arg), void *arg) { struct exit_function *new; + /* BZ#20544 */ + assert (func != NULL); + __libc_lock_lock (__exit_funcs_lock); new = __new_exitfn (&__exit_funcs);