delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/06/09/15:51:56

Date: Sun, 09 Jun 2002 20:58:00 +0100
From: "Richard Dawe" <rich AT phekda DOT freeserve DOT co DOT uk>
Sender: rich AT phekda DOT freeserve DOT co DOT uk
To: djgpp-workers AT delorie DOT com
X-Mailer: Emacs 21.3.50 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6
Subject: confstr.c and gcc 3.1
Message-Id: <E17H8j4-0000T4-00@phekda.freeserve.co.uk>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Here's a patch to avoid a call to snprintf to truncate a string in
confstr. OK to commit?

Thanks, bye, Rich =]

Index: src/libc/posix/unistd/confstr.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/unistd/confstr.c,v
retrieving revision 1.3
diff -p -u -3 -r1.3 confstr.c
--- src/libc/posix/unistd/confstr.c	2001/06/19 17:04:19	1.3
+++ src/libc/posix/unistd/confstr.c	2002/06/09 19:49:16
@@ -43,7 +43,9 @@ confstr(int name, char *buf, size_t len)
     case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
     case _CS_POSIX_V6_ILP32_OFF32_LIBS:
     {
-      out_len = snprintf(buf, len, "");
+      if (buf && (len > 0))
+	buf[0] = 0;
+      /* confstr includes the null terminator in its return value. */
       ++out_len;
       break;
     }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019