From a16e75cd3cb27ea5647774bc71625899f35b2fa6 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 8 Dec 2012 20:27:37 +0200 Subject: [PATCH] Fix putenv and unsetenv on MS-Windows. src/w32.c (unsetenv): Return 0 if the input string is too long. nt/inc/ms-w32.h (sys_putenv): Add prototype. Fixes: debbugs:13070 --- nt/ChangeLog | 1 + nt/inc/ms-w32.h | 1 + src/ChangeLog | 4 ++++ src/w32.c | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nt/ChangeLog b/nt/ChangeLog index df6a42595a..8cb9594d4d 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog @@ -1,6 +1,7 @@ 2012-12-08 Eli Zaretskii * inc/ms-w32.h (putenv): Redirect to sys_putenv. + (sys_putenv): Add prototype. * config.nt (HAVE_UNSETENV): Define to 1. diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h index 1cbcb7f88f..3d68efb804 100644 --- a/nt/inc/ms-w32.h +++ b/nt/inc/ms-w32.h @@ -381,6 +381,7 @@ extern char *get_emacs_configuration_options (void); # undef putenv #endif #define putenv sys_putenv +extern int sys_putenv (char *); extern int getloadavg (double *, int); extern int getpagesize (void); diff --git a/src/ChangeLog b/src/ChangeLog index 0be3eee672..222be9575b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2012-12-08 Eli Zaretskii + + * w32.c (unsetenv): Return 0 if the input string is too long. + 2012-12-08 Paul Eggert Use putenv+unsetenv instead of modifying environ directly (Bug#13070). diff --git a/src/w32.c b/src/w32.c index 203c5cd40f..b6bb653369 100644 --- a/src/w32.c +++ b/src/w32.c @@ -1562,7 +1562,7 @@ unsetenv (const char *name) if (name_len > 32767) { errno = ENOMEM; - return -1; + return 0; } /* It is safe to use 'alloca' with 32K size, since the stack is at least 2MB, and we set it to 8MB in the link command line. */ -- 2.39.2