]> sourceware.org Git - newlib-cygwin.git/commitdiff
* path.cc (readlink): Check if buffer length is positive. Truncate output to
authorChristopher Faylor <me@cgf.cx>
Mon, 4 Sep 2000 17:52:42 +0000 (17:52 +0000)
committerChristopher Faylor <me@cgf.cx>
Mon, 4 Sep 2000 17:52:42 +0000 (17:52 +0000)
buffer length.  Don't terminate buffer with '\0'.

14 files changed:
winsup/cygwin/ChangeLog
winsup/cygwin/dll_init.cc
winsup/cygwin/external.cc
winsup/cygwin/grp.cc
winsup/cygwin/init.cc
winsup/cygwin/passwd.cc
winsup/cygwin/path.cc
winsup/cygwin/pinfo.cc
winsup/cygwin/pipe.cc
winsup/cygwin/pthread.cc
winsup/cygwin/spawn.cc
winsup/cygwin/syscalls.cc
winsup/cygwin/termios.cc
winsup/cygwin/thread.cc

index 35845b3d9d1c4e04591737b6495b38792887c97b..bd008cfe9781c648555bb2c93d0cc8dc0c42960e 100644 (file)
@@ -1,3 +1,9 @@
+2000-09-03  Egor Duda  <deo@logos-m.ru>
+
+       * path.cc (readlink): Check if buffer length is positive.
+       Truncate output to buffer length. Don't terminate buffer
+       with '\0'.
+
 Sun Sep  3 00:38:40 2000  Christopher Faylor <cgf@cygnus.com>
 
        * environ.cc (environ_init): Don't free the new environment table after
index e7a5526709501ac0342d648d4d5822be5ea52a5d..7e94fa9f6707e82c3322a83ea0b4231c74de34e1 100644 (file)
@@ -41,7 +41,7 @@ per_module::run_ctors ()
       int i;
       for (i = 1; pfunc[i]; i++);
 
-      for (int j = i - 1; j > 0; j-- )
+      for (int j = i - 1; j > 0; j--)
        (pfunc[j]) ();
     }
 }
index 16303f56ef6486795e61767176c4bc4d92d9fb79..bfc4f1b257cee7893a4c7de8e8f1d5bfd7e8123f 100644 (file)
@@ -36,7 +36,7 @@ fillout_pinfo (pid_t pid, int winpid)
     i = 0;
 
   memset (&ep, 0, sizeof ep);
-  for (; i < pids.npids; )
+  for (; i < pids.npids;)
     {
       DWORD thispid = pids[i++];
       if (!thispid)
index a4af840f3304effd92f43ece4f2fd29d2843728f..9c4f3794affde19171d5da0b98020bd8ec3bb992 100644 (file)
@@ -266,7 +266,7 @@ getgroups (int gidsetsize, gid_t *grouplist, gid_t gid, const char *username)
   return cnt;
 
 error:
-  set_errno ( EINVAL );
+  set_errno (EINVAL);
   return -1;
 }
 
index 18342e0801173c416a9b609707b4649fc39b24df..f0c5a1cffdcd94b5382a5c5911bb4462d5e8a084 100644 (file)
@@ -28,7 +28,7 @@ WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load)
     case DLL_THREAD_ATTACH:
       if (user_data->threadinterface)
        {
-         if ( !TlsSetValue(user_data->threadinterface->reent_index,
+         if (!TlsSetValue(user_data->threadinterface->reent_index,
                    &user_data->threadinterface->reents))
            api_fatal("Sig proc MT init failed\n");
        }
index 98ea7b04d359a0bafca5c7badab4159448480ffd..a29a8a433fb35b2affd8c2203136d6bd1d9bde00 100644 (file)
@@ -178,8 +178,8 @@ search_for (uid_t uid, const char *name)
   /* Return default passwd entry if passwd is emulated or it's a
      request for the current user. */
   if (passwd_state != loaded
-      || (! name && uid == myself->uid)
-      || (  name && strcasematch(name, myself->username)))
+      || (!name && uid == myself->uid)
+      || (name && strcasematch(name, myself->username)))
     return default_pw;
 
   return NULL;
index 6400699ee85fd1cf791cb5fc5a3ff28bd8fe81a6..29df7b327a994e29642ecbec6439eea16dd04509 100644 (file)
@@ -2436,6 +2436,13 @@ int
 readlink (const char *path, char *buf, int buflen)
 {
   extern suffix_info stat_suffixes[];
+
+  if (buflen < 0)
+    {
+      set_errno (ENAMETOOLONG);
+      return -1;
+    }
+
   path_conv pathbuf (path, PC_SYM_CONTENTS, stat_suffixes);
 
   if (pathbuf.error)
@@ -2452,14 +2459,8 @@ readlink (const char *path, char *buf, int buflen)
       return -1;
     }
 
-  int len = strlen (pathbuf.get_win32 ());
-  if (len > (buflen - 1))
-    {
-      set_errno (ENAMETOOLONG);
-      return -1;
-    }
+  int len = max (buflen, (int) strlen (pathbuf.get_win32 ()));
   memcpy (buf, pathbuf.get_win32 (), len);
-  buf[len] = '\0';
 
   /* errno set by symlink.check if error */
   return len;
index 9ccb8675aa0b7ccb2b0dcac206dd79cae7e246e5..37a2808992712756ed536b1f25e93f87ba9c9bca 100644 (file)
@@ -96,7 +96,7 @@ struct sigaction&
 _pinfo::getsig(int sig)
 {
 #ifdef _MT_SAFE
-  if ( thread2signal )
+  if (thread2signal)
     return thread2signal->sigs[sig];
   return sigs[sig];
 #else
@@ -108,7 +108,7 @@ sigset_t&
 _pinfo::getsigmask ()
 {
 #ifdef _MT_SAFE
-  if ( thread2signal )
+  if (thread2signal)
     return *thread2signal->sigmask;
   return sig_mask;
 #else
@@ -120,7 +120,7 @@ void
 _pinfo::setsigmask (sigset_t _mask)
 {
 #ifdef _MT_SAFE
-  if ( thread2signal )
+  if (thread2signal)
        *(thread2signal->sigmask) = _mask;
   sig_mask=_mask;
 #else
@@ -132,7 +132,7 @@ LONG *
 _pinfo::getsigtodo(int sig)
 {
 #ifdef _MT_SAFE
-  if ( thread2signal )
+  if (thread2signal)
     return thread2signal->sigtodo + __SIGOFFSET + sig;
   return _sigtodo + __SIGOFFSET + sig;
 #else
@@ -146,7 +146,7 @@ HANDLE
 _pinfo::getthread2signal()
 {
 #ifdef _MT_SAFE
-  if ( thread2signal )
+  if (thread2signal)
     return thread2signal->win32_obj_id;
   return hMainThread;
 #else
index 0031aff6795cd01b3914ede7a3b941f5d0f68755..3a103e1ca17b3f03494ebb077991531516c867f4 100644 (file)
@@ -29,7 +29,7 @@ make_pipe (int fildes[2], unsigned int psize, int mode)
   if ((fdr = fdtab.find_unused_handle ()) < 0)
     set_errno (ENMFILE);
   else if ((fdw = fdtab.find_unused_handle (fdr + 1)) < 0)
-    set_errno ( ENMFILE);
+    set_errno (ENMFILE);
   else if (!CreatePipe (&r, &w, sa, psize))
     __seterrno ();
   else
index 2a2287b0d00fb749344ab64e651ea307b1362f53..82200e4a7664be8f35d7799fe055a8eab134f829 100644 (file)
@@ -137,7 +137,7 @@ pthread_self ()
 int
 pthread_equal (pthread_t t1, pthread_t t2)
 {
-  return __pthread_equal ( &t1, &t2);
+  return __pthread_equal (&t1, &t2);
 }
 
 /* Mutexes  */
index 770fea46d44bf06cfbc72b0cec8300e328c1c2b6..39e2b391a9871aa4cf1156742eb74733bb3fd641 100644 (file)
@@ -513,7 +513,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
   ciresrv.moreinfo->environ = (char **) cmalloc (HEAP_ARGV, envsize (envp, 1));
   char **c;
   const char * const *e;
-  for (c = ciresrv.moreinfo->environ, e = envp; *e; )
+  for (c = ciresrv.moreinfo->environ, e = envp; *e;)
     *c++ = cstrdup (*e++);
   *c = NULL;
   if (mode != _P_OVERLAY ||
index 876ed4ceed2771b9acb6d972b9deb0535cd455e7..c95eef38bac4174324567a3b2fb49fce6ffa56f7 100644 (file)
@@ -601,8 +601,7 @@ _link (const char *a, const char *b)
            &dwBytesWritten,
            TRUE,               // abort
            FALSE,              // don't process security
-           &lpContext
-           );
+           &lpContext);
        }
       else
        syscall_printf ("cannot write streamId, %E");
@@ -1635,7 +1634,7 @@ get_osfhandle (int fd)
 
   if (fdtab.not_open (fd))
     {
-      set_errno ( EBADF);
+      set_errno (EBADF);
     }
   else
     {
index e30bb60effa8e6393f43ef4a195abe081b19d1a8..52fe489ee4b21b460129893e60347d8804c8e3ef 100644 (file)
@@ -42,7 +42,7 @@ tcsendbreak (int fd, int duration)
     }
 
 out:
-  syscall_printf ("%d = tcsendbreak (%d, %d )", res, fd, duration);
+  syscall_printf ("%d = tcsendbreak (%d, %d)", res, fd, duration);
   return res;
 }
 
index d685ef37d22a0aa2adfa69d19ef613a33126fa63..49e52232ebd09ce36d86d3e92b2f776abebd5afe 100644 (file)
@@ -241,13 +241,13 @@ MTinterface::SetItem (int _index, MTitem * _item, MTList * _list)
 int
 CmpPthreadObj (void *_i, void *_value)
 {
-  return ( (MTitem *) _i)->Id () == * (int *) _value;
+  return ((MTitem *) _i)->Id () == *(int *) _value;
 };
 
 int
 CmpThreadId (void *_i, void *_id)
 {
-  return ( (ThreadItem *) _i)->thread_id == * (DWORD *) _id;
+  return ((ThreadItem *) _i)->thread_id == * (DWORD *) _id;
 };
 
 void
This page took 0.047183 seconds and 5 git commands to generate.