summaryrefslogtreecommitdiff
path: root/src/w32.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/w32.c b/src/w32.c
index b51022c6001..da778eb8541 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -908,8 +908,18 @@ static char startup_dir[MAXPATHLEN];
/* Get the current working directory. */
char *
-getwd (char *dir)
+getcwd (char *dir, size_t dirsize)
{
+ if (!dirsize)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ if (dirsize <= strlen (startup_dir))
+ {
+ errno = ERANGE;
+ return NULL;
+ }
#if 0
if (GetCurrentDirectory (MAXPATHLEN, dir) > 0)
return dir;
@@ -1825,7 +1835,7 @@ init_environment (char ** argv)
memcpy (*envp, "COMSPEC=", 8);
}
- /* Remember the initial working directory for getwd. */
+ /* Remember the initial working directory for getcwd. */
/* FIXME: Do we need to resolve possible symlinks in startup_dir?
Does it matter anywhere in Emacs? */
if (!GetCurrentDirectory (MAXPATHLEN, startup_dir))