Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-09-04 21:52:42 +0400
committerChristopher Faylor <me@cgf.cx>2000-09-04 21:52:42 +0400
commitf76325499abbd5e5212cbe7b479008e3bf1b1a96 (patch)
tree929c38930f469b7d0e53193223c30101081f9ecf
parent9c136d7ea6c180419f55b166c9acfed2ac6e2221 (diff)
* path.cc (readlink): Check if buffer length is positive. Truncate output to
buffer length. Don't terminate buffer with '\0'.
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/dll_init.cc2
-rw-r--r--winsup/cygwin/external.cc2
-rw-r--r--winsup/cygwin/grp.cc2
-rw-r--r--winsup/cygwin/init.cc2
-rw-r--r--winsup/cygwin/passwd.cc4
-rw-r--r--winsup/cygwin/path.cc15
-rw-r--r--winsup/cygwin/pinfo.cc10
-rw-r--r--winsup/cygwin/pipe.cc2
-rw-r--r--winsup/cygwin/pthread.cc2
-rw-r--r--winsup/cygwin/spawn.cc2
-rw-r--r--winsup/cygwin/syscalls.cc5
-rw-r--r--winsup/cygwin/termios.cc2
-rw-r--r--winsup/cygwin/thread.cc4
14 files changed, 33 insertions, 27 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 35845b3d9..bd008cfe9 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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
diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index e7a552670..7e94fa9f6 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -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]) ();
}
}
diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc
index 16303f56e..bfc4f1b25 100644
--- a/winsup/cygwin/external.cc
+++ b/winsup/cygwin/external.cc
@@ -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)
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index a4af840f3..9c4f3794a 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -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;
}
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index 18342e080..f0c5a1cff 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -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");
}
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index 98ea7b04d..a29a8a433 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -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;
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 6400699ee..29df7b327 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -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;
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 9ccb8675a..37a280899 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -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
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 0031aff67..3a103e1ca 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -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
diff --git a/winsup/cygwin/pthread.cc b/winsup/cygwin/pthread.cc
index 2a2287b0d..82200e4a7 100644
--- a/winsup/cygwin/pthread.cc
+++ b/winsup/cygwin/pthread.cc
@@ -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 */
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 770fea46d..39e2b391a 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -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 ||
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 876ed4cee..c95eef38b 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -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
{
diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc
index e30bb60ef..52fe489ee 100644
--- a/winsup/cygwin/termios.cc
+++ b/winsup/cygwin/termios.cc
@@ -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;
}
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index d685ef37d..49e52232e 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -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