From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22779 invoked by alias); 21 Jul 2005 09:32:15 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 22763 invoked by uid 22791); 21 Jul 2005 09:32:15 -0000 Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 21 Jul 2005 09:32:15 +0000 Received: from sunsite.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id j6L9W2g4027789; Thu, 21 Jul 2005 11:32:02 +0200 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.1/8.13.1/Submit) id j6L9W1nJ027788; Thu, 21 Jul 2005 11:32:01 +0200 Date: Thu, 21 Jul 2005 09:32:00 -0000 From: Jakub Jelinek To: Ulrich Drepper , Roland McGrath Cc: Glibc hackers Subject: [PATCH] Fix swprintf (buf, n, L"format") Message-ID: <20050721093201.GC15708@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-SW-Source: 2005-07/txt/msg00037.txt.bz2 Hi! The _FORTIFY_SOURCE swprintf macro will not work if there are no arguments after format. 2005-07-21 Jakub Jelinek * wcsmbs/bits/wchar2.h (swprintf): Remove format argument. * debug/tst-chk1.c (do_test): Add test for swprintf with format being the last argument. --- libc/wcsmbs/bits/wchar2.h.jj 2005-07-20 09:35:31.000000000 +0200 +++ libc/wcsmbs/bits/wchar2.h 2005-07-20 09:35:31.000000000 +0200 @@ -199,11 +199,10 @@ extern int __swprintf_chk (wchar_t *__re __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */; /* XXX We might want to have support in gcc for swprintf. */ -#define swprintf(s, n, format, ...) \ +#define swprintf(s, n, ...) \ (__bos (s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1 \ - ? __swprintf_chk (s, n, __USE_FORTIFY_LEVEL - 1, __bos (s), format, \ - __VA_ARGS__) \ - : swprintf (s, n, format, __VA_ARGS__)) + ? __swprintf_chk (s, n, __USE_FORTIFY_LEVEL - 1, __bos (s), __VA_ARGS__) \ + : swprintf (s, n, __VA_ARGS__)) extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n, --- libc/debug/tst-chk1.c.jj 2005-07-20 10:32:42.000000000 +0200 +++ libc/debug/tst-chk1.c 2005-07-21 11:23:08.000000000 +0200 @@ -403,6 +403,10 @@ do_test (void) || wmemcmp (wbuf, L"aabcEDX98", 10)) FAIL (); + if (swprintf (wbuf + 7, 3, L"64") != 2 + || wmemcmp (wbuf, L"aabcEDX64", 10)) + FAIL (); + /* These ops need runtime checking, but shouldn't __chk_fail. */ wmemcpy (wbuf, L"abcdefghij", l0 + 10); wmemmove (wbuf + 1, wbuf, l0 + 9); Jakub