honeyd/setenv.c

Sat, 01 Sep 2012 12:17:10 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 01 Sep 2012 12:17:10 +0200
changeset 653
9d74c60eb90e
permissions
-rw-r--r--

Back out attempt to repair gets(3) redefinition and correct rather by
avoiding detection of gets(3) as a method with no macro, otherwise
leading to definition of HAVE_RAW_DECL_GETS and redefition of gets(3)
in lib/stdio.h(.in) caused by 'a split double-inclusion guard' and
a seemingly multiple '#include_next <stdio.h>' reference. Quatch.

     2 #ifndef HAVE_SETENV
     3 #ifdef HAVE_CONFIG_H
     4 #include "config.h"
     5 #endif
     6 #include <sys/types.h>
     7 #include <stdlib.h>
     8 #include <string.h>
    10 int setenv(const char *kszName, const char *kszValue, int nOverwrite)
    11 {
    12     char *szPair = NULL;
    14     if (nOverwrite == 0 && getenv(kszName) != 0)
    15         return 0;
    16     szPair = malloc(strlen(kszName) + 1 + strlen(kszValue) + 1);
    17     if (szPair == NULL)
    18         return -1;
    19     strcpy(szPair, kszName);
    20     strcat(szPair, "=");
    21     strcat(szPair, kszValue);
    22     putenv(szPair);
    23     return 0;
    24 }
    25 #endif /* !HAVE_SETENV */

mercurial