From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1014 invoked by alias); 12 Mar 2010 09:45:02 -0000 Received: (qmail 949 invoked by uid 22791); 12 Mar 2010 09:45:02 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Mar 2010 09:44:58 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2C9ivcw030988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 12 Mar 2010 04:44:57 -0500 Received: from hase.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2C9itnM019482 for ; Fri, 12 Mar 2010 04:44:56 -0500 From: Andreas Schwab To: libc-hacker@sourceware.org Subject: [PATCH] Don't underestimate length of DST substitution X-Yow: Don't worry, nobody really LISTENS to lectures in MOSCOW, either! .. FRENCH, HISTORY, ADVANCED CALCULUS, COMPUTER PROGRAMMING, BLACK STUDIES, SOCIOBIOLOGY!.. Are there any QUESTIONS?? Date: Fri, 12 Mar 2010 09:45:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00005.txt.bz2 2010-03-12 Andreas Schwab * elf/dl-dst.h: Include "trusted-dirs.h". (DL_DST_REQUIRED): Take $LIB into account. --- elf/dl-dst.h | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/elf/dl-dst.h b/elf/dl-dst.h index 76076a6..81be8be 100644 --- a/elf/dl-dst.h +++ b/elf/dl-dst.h @@ -18,6 +18,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include "trusted-dirs.h" + /* Determine the number of DST elements in the name. Only if IS_PATH is nonzero paths are recognized (i.e., multiple, ':' separated filenames). */ #define DL_DST_COUNT(name, is_path) \ @@ -39,12 +41,13 @@ \ if (__cnt > 0) \ { \ - size_t origin_len; \ + size_t dst_len; \ /* Now we make a guess how many extra characters on top of the \ length of S we need to represent the result. We know that \ we have CNT replacements. Each at most can use \ - MAX (strlen (ORIGIN), strlen (_dl_platform)) \ - minus 7 (which is the length of "$ORIGIN"). \ + MAX (MAX (strlen (ORIGIN), strlen (_dl_platform)), \ + strlen (DL_DST_LIB)) \ + minus 4 (which is the length of "$LIB"). \ \ First get the origin string if it is not available yet. \ This can only happen for the map of the executable. */ \ @@ -53,14 +56,16 @@ { \ assert ((l)->l_name[0] == '\0'); \ (l)->l_origin = _dl_get_origin (); \ - origin_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \ + dst_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \ ? strlen ((l)->l_origin) : 0); \ } \ else \ - origin_len = (l)->l_origin == (char *) -1 \ + dst_len = (l)->l_origin == (char *) -1 \ ? 0 : strlen ((l)->l_origin); \ - \ - __len += __cnt * (MAX (origin_len, GLRO(dl_platformlen)) - 7); \ + dst_len = MAX (MAX (dst_len, GLRO(dl_platformlen)), \ + strlen (DL_DST_LIB)); \ + if (dst_len > 4) \ + __len += __cnt * (dst_len - 4); \ } \ \ __len; }) @@ -72,7 +77,7 @@ if ((l) == NULL) \ { \ const char *origin = _dl_get_origin (); \ - origin_len = (origin && origin != (char *) -1 ? strlen (origin) : 0); \ + dst_len = (origin && origin != (char *) -1 ? strlen (origin) : 0); \ } \ else #endif -- 1.7.0.1 Andreas. -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different."