Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src PR/46360: YAMAMOTO Takashi: Restore NetBSD-5 compatibility w...



details:   https://anonhg.NetBSD.org/src/rev/adfdeb3b230c
branches:  trunk
changeset: 778924:adfdeb3b230c
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 20 17:31:29 2012 +0000

description:
PR/46360: YAMAMOTO Takashi: Restore NetBSD-5 compatibility with putenv()
copying the passed string (which is not ToG compliant), instead of using
it directly in the environment arrat as it should. Needs to be pulled up
to NetBSd-6.

diffstat:

 include/stdlib.h                       |   6 +-
 lib/libc/compat/include/stdlib.h       |   4 +-
 lib/libc/compat/stdlib/Makefile.inc    |   4 +-
 lib/libc/compat/stdlib/compat_putenv.c |  70 ++++++++++++++++++++++++++++++++++
 4 files changed, 79 insertions(+), 5 deletions(-)

diffs (123 lines):

diff -r 25a3315e0bc5 -r adfdeb3b230c include/stdlib.h
--- a/include/stdlib.h  Fri Apr 20 16:20:45 2012 +0000
+++ b/include/stdlib.h  Fri Apr 20 17:31:29 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stdlib.h,v 1.97 2011/03/16 00:48:34 christos Exp $     */
+/*     $NetBSD: stdlib.h,v 1.98 2012/04/20 17:31:29 christos Exp $     */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -160,7 +160,9 @@
         seed48(unsigned short[3]);
 void    srand48(long);
 
-int     putenv(char *);
+#ifndef __LIBC12_SOURCE__
+int     putenv(char *) __RENAME(__putenv50);
+#endif
 #endif
 
 
diff -r 25a3315e0bc5 -r adfdeb3b230c lib/libc/compat/include/stdlib.h
--- a/lib/libc/compat/include/stdlib.h  Fri Apr 20 16:20:45 2012 +0000
+++ b/lib/libc/compat/include/stdlib.h  Fri Apr 20 17:31:29 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stdlib.h,v 1.4 2009/01/26 15:05:56 drochner Exp $      */
+/*     $NetBSD: stdlib.h,v 1.5 2012/04/20 17:31:29 christos Exp $      */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -38,6 +38,8 @@
 
 void    unsetenv(const char *);
 int     __unsetenv13(const char *);
+int     putenv(char *);
+int     __putenv50(char *);
 __aconst char *devname(int32_t, mode_t);
 __aconst char *__devname50(dev_t, mode_t);
 
diff -r 25a3315e0bc5 -r adfdeb3b230c lib/libc/compat/stdlib/Makefile.inc
--- a/lib/libc/compat/stdlib/Makefile.inc       Fri Apr 20 16:20:45 2012 +0000
+++ b/lib/libc/compat/stdlib/Makefile.inc       Fri Apr 20 17:31:29 2012 +0000
@@ -1,5 +1,5 @@
-#      $NetBSD: Makefile.inc,v 1.2 2006/03/11 21:07:18 christos Exp $
+#      $NetBSD: Makefile.inc,v 1.3 2012/04/20 17:31:30 christos Exp $
 
 .PATH: ${COMPATDIR}/stdlib
 CPPFLAGS+=-I${COMPATDIR}/stdlib -I${COMPATDIR}/../stdlib
-SRCS+=compat_unsetenv.c 
+SRCS+=compat_putenv.c compat_unsetenv.c
diff -r 25a3315e0bc5 -r adfdeb3b230c lib/libc/compat/stdlib/compat_putenv.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/compat/stdlib/compat_putenv.c    Fri Apr 20 17:31:29 2012 +0000
@@ -0,0 +1,70 @@
+/*     $NetBSD: compat_putenv.c,v 1.1 2012/04/20 17:31:30 christos Exp $       */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: compat_putenv.c,v 1.1 2012/04/20 17:31:30 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#define __LIBC12_SOURCE__
+#include "namespace.h"
+
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include <compat/include/stdlib.h>
+
+#include "reentrant.h"
+#include "local.h"
+
+#ifdef __weak_alias
+__weak_alias(putenv,_putenv)
+#endif
+
+__warn_references(unsetenv,
+    "warning: reference to compatibility putenv();"
+    " include <stdlib.h> for correct reference")
+
+/*
+ * putenv(name) --
+ *     This version copies the string for compatibility.
+ */
+int
+putenv(char *name)
+{
+       char *copy;
+
+       _DIAGASSERT(name != NULL);
+
+       if ((copy = strdup(name)) == NULL)
+               return -1;
+
+       return __putenv50(copy);
+}



Home | Main Index | Thread Index | Old Index