projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
math: fix a regression in powl and do some cleanups
[musl]
/
src
/
unistd
/
getcwd.c
diff --git
a/src/unistd/getcwd.c
b/src/unistd/getcwd.c
index
b64b560
..
2e540cd
100644
(file)
--- a/
src/unistd/getcwd.c
+++ b/
src/unistd/getcwd.c
@@
-1,8
+1,13
@@
#include <unistd.h>
#include <errno.h>
#include <unistd.h>
#include <errno.h>
+#include <limits.h>
+#include <string.h>
#include "syscall.h"
char *getcwd(char *buf, size_t size)
{
#include "syscall.h"
char *getcwd(char *buf, size_t size)
{
- return syscall(SYS_getcwd, buf, size) < 0 ? NULL : buf;
+ char tmp[PATH_MAX];
+ if (!buf) buf = tmp, size = PATH_MAX;
+ if (syscall(SYS_getcwd, buf, size) < 0) return 0;
+ return buf == tmp ? strdup(buf) : buf;
}
}