aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-02-16 09:43:19 +0000
committerCorinna Vinschen <corinna@vinschen.de>2008-02-16 09:43:19 +0000
commite2108ce092c8e887cc9422202dff64777d0794f7 (patch)
tree06a884a113f5506ff1548f25e87ac4e92e64417c
parent9d342d561eb967985e4eb37010ead620f2c466ba (diff)
downloadnewlib-e2108ce092c8e887cc9422202dff64777d0794f7.zip
newlib-e2108ce092c8e887cc9422202dff64777d0794f7.tar.gz
newlib-e2108ce092c8e887cc9422202dff64777d0794f7.tar.bz2
* fhandler.cc (fhandler_base::fpathconf): Fix _PC_NAME_MAX and
_PC_PATH_MAX cases.
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/fhandler.cc12
2 files changed, 15 insertions, 2 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 948edce..663f06d 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-16 Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler.cc (fhandler_base::fpathconf): Fix _PC_NAME_MAX and
+ _PC_PATH_MAX cases.
+
2008-02-15 Corinna Vinschen <corinna@vinschen.de>
* include/sys/cygwin.h (__INT_MAX_PATH): Remove.
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 75528d3..f47805b 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1541,6 +1541,8 @@ fhandler_base::fsync ()
int
fhandler_base::fpathconf (int v)
{
+ int ret;
+
switch (v)
{
case _PC_LINK_MAX:
@@ -1558,10 +1560,16 @@ fhandler_base::fpathconf (int v)
break;
case _PC_NAME_MAX:
/* NAME_MAX is without trailing \0 */
- return pc.isdir () ? PATH_MAX - strlen (get_name ()) - 2 : NAME_MAX;
+ if (!pc.isdir ())
+ return NAME_MAX;
+ ret = NT_MAX_PATH - strlen (get_name ()) - 2;
+ return ret < 0 ? 0 : ret > NAME_MAX ? NAME_MAX : ret;
case _PC_PATH_MAX:
/* PATH_MAX is with trailing \0 */
- return pc.isdir () ? PATH_MAX - strlen (get_name ()) - 1 : PATH_MAX;
+ if (!pc.isdir ())
+ return PATH_MAX;
+ ret = NT_MAX_PATH - strlen (get_name ()) - 1;
+ return ret < 0 ? 0 : ret > PATH_MAX ? PATH_MAX : ret;
case _PC_PIPE_BUF:
if (pc.isdir ()
|| get_device () == FH_FIFO || get_device () == FH_PIPE