[Glibc-bsd-commits] r2825 - trunk/glibc-ports/kfreebsd

Aurelien Jarno aurel32 at alioth.debian.org
Fri Nov 13 11:29:15 UTC 2009


Author: aurel32
Date: 2009-11-13 11:29:15 +0000 (Fri, 13 Nov 2009)
New Revision: 2825

Modified:
   trunk/glibc-ports/kfreebsd/faccessat.c
   trunk/glibc-ports/kfreebsd/fchmodat.c
   trunk/glibc-ports/kfreebsd/fchownat.c
   trunk/glibc-ports/kfreebsd/futimesat.c
   trunk/glibc-ports/kfreebsd/fxstatat.c
   trunk/glibc-ports/kfreebsd/fxstatat64.c
   trunk/glibc-ports/kfreebsd/linkat.c
   trunk/glibc-ports/kfreebsd/mkdirat.c
   trunk/glibc-ports/kfreebsd/openat.c
   trunk/glibc-ports/kfreebsd/readlinkat.c
   trunk/glibc-ports/kfreebsd/renameat.c
   trunk/glibc-ports/kfreebsd/symlinkat.c
   trunk/glibc-ports/kfreebsd/unlinkat.c
   trunk/glibc-ports/kfreebsd/xmknodat.c
Log:
*at.c: Fix handling of empty parameters for file names in
case the syscall is not available. Backported from Linux version.



Modified: trunk/glibc-ports/kfreebsd/faccessat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/faccessat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/faccessat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -68,6 +68,7 @@
 	  int mib[4];
 	  size_t kf_len = 0;
 	  char *kf_buf, *kf_bufp;
+	  size_t filelen;
 
 	  if (fd < 0)
 	    {
@@ -75,6 +76,13 @@
 	      return -1;
 	    }
 
+	  filelen = strlen (file);
+	  if (__builtin_expect (filelen == 0, 0))
+	    {
+	      __set_errno (ENOENT);
+	      return -1;
+	    }
+
 	  mib[0] = CTL_KERN;
 	  mib[1] = KERN_PROC;
 	  mib[2] = KERN_PROC_FILEDESC;
@@ -86,7 +94,7 @@
 	      return -1;
 	    }
 
-	  kf_buf = alloca (kf_len + strlen (file));
+	  kf_buf = alloca (kf_len + filelen);
 	  if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	    {
 	      __set_errno (ENOSYS);

Modified: trunk/glibc-ports/kfreebsd/fchmodat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/fchmodat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/fchmodat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -68,6 +68,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t filelen;
 
       if (fd < 0)
 	{
@@ -75,6 +76,13 @@
 	  return -1;
 	}
 
+      filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -86,7 +94,7 @@
 	  return -1;
 	}
 
-      kf_buf = alloca (kf_len + strlen (file));
+      kf_buf = alloca (kf_len + filelen);
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{
 	  __set_errno (ENOSYS);

Modified: trunk/glibc-ports/kfreebsd/fchownat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/fchownat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/fchownat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -67,6 +67,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t filelen;
 
       if (fd < 0)
 	{
@@ -74,6 +75,13 @@
 	  return -1;
 	}
 
+      filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -85,7 +93,7 @@
 	  return -1;
 	}
 
-      kf_buf = alloca (kf_len + strlen (file));
+      kf_buf = alloca (kf_len + filelen);
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{
 	  __set_errno (ENOSYS);

Modified: trunk/glibc-ports/kfreebsd/futimesat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/futimesat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/futimesat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -65,6 +65,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t filelen;
 
       if (fd < 0)
 	{
@@ -72,6 +73,13 @@
 	  return -1;
 	}
 
+      filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -86,7 +94,7 @@
       if (file == NULL)
 	kf_buf = alloca (kf_len);
       else
-	kf_buf = alloca (kf_len + strlen (file));
+	kf_buf = alloca (kf_len + filelen);
 
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{

Modified: trunk/glibc-ports/kfreebsd/fxstatat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/fxstatat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/fxstatat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -86,6 +86,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t filelen;
 
       if (fd < 0)
 	{
@@ -93,6 +94,13 @@
 	  return -1;
 	}
 
+      filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -104,7 +112,7 @@
 	  return -1;
 	}
 
-      kf_buf = alloca (kf_len + strlen (file));
+      kf_buf = alloca (kf_len + filelen);
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{
 	  __set_errno (ENOSYS);

Modified: trunk/glibc-ports/kfreebsd/fxstatat64.c
===================================================================
--- trunk/glibc-ports/kfreebsd/fxstatat64.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/fxstatat64.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -80,6 +80,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t filelen;
 
       if (fd < 0)
 	{
@@ -87,6 +88,13 @@
 	  return -1;
 	}
 
+      filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -98,7 +106,7 @@
 	  return -1;
 	}
 
-      kf_buf = alloca (kf_len + strlen (file));
+      kf_buf = alloca (kf_len + filelen);
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{
 	  __set_errno (ENOSYS);

Modified: trunk/glibc-ports/kfreebsd/linkat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/linkat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/linkat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -70,6 +70,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t fromlen, tolen;
 
       if ((fromfd < 0) || (tofd < 0))
 	{
@@ -77,6 +78,15 @@
 	  return -1;
 	}
 
+      fromlen = strlen (from);
+      tolen = strlen (to);
+      if (__builtin_expect (fromlen == 0, 0)
+	  || __builtin_expect (tolen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -113,7 +123,7 @@
 		      return -1;
 		    }
 
-		  buf = alloca (strlen (kf->kf_path) + strlen (from) + 2);
+		  buf = alloca (strlen (kf->kf_path) + fromlen + 2);
 		  strcpy(buf, kf->kf_path);
 		  strcat (buf, "/");
 		  strcat (buf, from);
@@ -148,7 +158,7 @@
 		      return -1;
 		    }
 
-		  buf = alloca (strlen (kf->kf_path) + strlen (to) + 2);
+		  buf = alloca (strlen (kf->kf_path) + tolen + 2);
 		  strcpy(buf, kf->kf_path);
 		  strcat (buf, "/");
 		  strcat (buf, to);

Modified: trunk/glibc-ports/kfreebsd/mkdirat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/mkdirat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/mkdirat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -59,6 +59,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t filelen;
 
       if (fd < 0)
 	{
@@ -66,6 +67,13 @@
 	  return -1;
 	}
 
+      filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -77,7 +85,7 @@
 	  return -1;
 	}
 
-      kf_buf = alloca (kf_len + strlen (file));
+      kf_buf = alloca (kf_len + filelen);
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{
 	  __set_errno (ENOSYS);

Modified: trunk/glibc-ports/kfreebsd/openat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/openat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/openat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -67,6 +67,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t filelen;
 
       if (fd < 0)
 	{
@@ -74,6 +75,13 @@
 	  return -1;
 	}
 
+      filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -85,7 +93,7 @@
 	  return -1;
 	}
 
-      kf_buf = alloca (kf_len + strlen (file));
+      kf_buf = alloca (kf_len + filelen);
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{
 	  __set_errno (ENOSYS);
@@ -175,6 +183,7 @@
 	  int mib[4];
 	  size_t kf_len = 0;
 	  char *kf_buf, *kf_bufp;
+	  size_t filelen;
 
 	  if (fd < 0)
 	    {
@@ -182,6 +191,13 @@
 	      return -1;
 	    }
 
+	  filelen = strlen (file);
+	  if (__builtin_expect (filelen == 0, 0))
+	    {
+	      __set_errno (ENOENT);
+	      return -1;
+	    }
+
 	  mib[0] = CTL_KERN;
 	  mib[1] = KERN_PROC;
 	  mib[2] = KERN_PROC_FILEDESC;
@@ -193,7 +209,7 @@
 	      return -1;
 	    }
 
-	  kf_buf = alloca (kf_len + strlen (file));
+	  kf_buf = alloca (kf_len + filelen);
 	  if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	    {
 	      __set_errno (ENOSYS);

Modified: trunk/glibc-ports/kfreebsd/readlinkat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/readlinkat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/readlinkat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -61,6 +61,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t pathlen;
 
       if (fd < 0)
 	{
@@ -68,6 +69,13 @@
 	  return -1;
 	}
 
+      pathlen = strlen (path);
+      if (__builtin_expect (pathlen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -79,7 +87,7 @@
 	  return -1;
 	}
 
-      kf_buf = alloca (kf_len + strlen (path));
+      kf_buf = alloca (kf_len + pathlen);
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{
 	  __set_errno (ENOSYS);

Modified: trunk/glibc-ports/kfreebsd/renameat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/renameat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/renameat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -62,6 +62,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t old_filelen, new_filelen;
 
       if ((oldfd < 0) || (newfd < 0))
 	{
@@ -69,6 +70,14 @@
 	  return -1;
 	}
 
+      old_filelen = strlen (old);
+      if (__builtin_expect (old_filelen == 0, 0)
+	  || __builtin_expect (new_filelen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -105,7 +114,7 @@
 		      return -1;
 		    }
 
-		  buf = alloca (strlen (kf->kf_path) + strlen (old) + 2);
+		  buf = alloca (strlen (kf->kf_path) + old_filelen + 2);
 		  strcpy(buf, kf->kf_path);
 		  strcat (buf, "/");
 		  strcat (buf, old);
@@ -140,7 +149,7 @@
 		      return -1;
 		    }
 
-		  buf = alloca (strlen (kf->kf_path) + strlen (new) + 2);
+		  buf = alloca (strlen (kf->kf_path) + new_filelen + 2);
 		  strcpy(buf, kf->kf_path);
 		  strcat (buf, "/");
 		  strcat (buf, new);

Modified: trunk/glibc-ports/kfreebsd/symlinkat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/symlinkat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/symlinkat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -59,6 +59,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t tolen;
 
       if (tofd < 0)
 	{
@@ -66,6 +67,13 @@
 	  return -1;
 	}
 
+      tolen = strlen (to);
+      if (__builtin_expect (tolen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -77,7 +85,7 @@
 	  return -1;
 	}
 
-      kf_buf = alloca (kf_len + strlen (to));
+      kf_buf = alloca (kf_len + tolen);
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{
 	  __set_errno (ENOSYS);

Modified: trunk/glibc-ports/kfreebsd/unlinkat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/unlinkat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/unlinkat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -66,6 +66,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t filelen;
 
       if (fd < 0)
 	{
@@ -73,6 +74,13 @@
 	  return -1;
 	}
 
+      filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -84,7 +92,7 @@
 	  return -1;
 	}
 
-      kf_buf = alloca (kf_len + strlen (file));
+      kf_buf = alloca (kf_len + filelen);
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{
 	  __set_errno (ENOSYS);

Modified: trunk/glibc-ports/kfreebsd/xmknodat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/xmknodat.c	2009-11-13 10:17:22 UTC (rev 2824)
+++ trunk/glibc-ports/kfreebsd/xmknodat.c	2009-11-13 11:29:15 UTC (rev 2825)
@@ -76,6 +76,7 @@
       int mib[4];
       size_t kf_len = 0;
       char *kf_buf, *kf_bufp;
+      size_t filelen;
 
       if (fd < 0)
 	{
@@ -83,6 +84,13 @@
 	  return -1;
 	}
 
+      filelen = strlen (file);
+      if (__builtin_expect (filelen == 0, 0))
+	{
+	  __set_errno (ENOENT);
+	  return -1;
+	}
+
       mib[0] = CTL_KERN;
       mib[1] = KERN_PROC;
       mib[2] = KERN_PROC_FILEDESC;
@@ -94,7 +102,7 @@
 	  return -1;
 	}
 
-      kf_buf = alloca (kf_len + strlen (file));
+      kf_buf = alloca (kf_len + filelen);
       if (__sysctl (mib, 4, kf_buf, &kf_len, NULL, 0) != 0)
 	{
 	  __set_errno (ENOSYS);




More information about the Glibc-bsd-commits mailing list