public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix swprintf (buf, n, L"format")
@ 2005-07-21  9:32 Jakub Jelinek
  2005-07-21 16:22 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2005-07-21  9:32 UTC (permalink / raw)
  To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers

Hi!

The _FORTIFY_SOURCE swprintf macro will not work if there are no
arguments after format.

2005-07-21  Jakub Jelinek  <jakub@redhat.com>

	* 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix swprintf (buf, n, L"format")
  2005-07-21  9:32 [PATCH] Fix swprintf (buf, n, L"format") Jakub Jelinek
@ 2005-07-21 16:22 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2005-07-21 16:22 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

[-- Attachment #1: Type: text/plain, Size: 101 bytes --]

Applied.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-07-21 16:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-21  9:32 [PATCH] Fix swprintf (buf, n, L"format") Jakub Jelinek
2005-07-21 16:22 ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).