* path.cc (readlink): Check if buffer length is positive. Truncate output to
buffer length. Don't terminate buffer with '\0'.
This commit is contained in:
parent
9c136d7ea6
commit
f76325499a
|
@ -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>
|
Sun Sep 3 00:38:40 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* environ.cc (environ_init): Don't free the new environment table after
|
* environ.cc (environ_init): Don't free the new environment table after
|
||||||
|
|
|
@ -41,7 +41,7 @@ per_module::run_ctors ()
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; pfunc[i]; 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]) ();
|
(pfunc[j]) ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ fillout_pinfo (pid_t pid, int winpid)
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
memset (&ep, 0, sizeof ep);
|
memset (&ep, 0, sizeof ep);
|
||||||
for (; i < pids.npids; )
|
for (; i < pids.npids;)
|
||||||
{
|
{
|
||||||
DWORD thispid = pids[i++];
|
DWORD thispid = pids[i++];
|
||||||
if (!thispid)
|
if (!thispid)
|
||||||
|
|
|
@ -266,7 +266,7 @@ getgroups (int gidsetsize, gid_t *grouplist, gid_t gid, const char *username)
|
||||||
return cnt;
|
return cnt;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
set_errno ( EINVAL );
|
set_errno (EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load)
|
||||||
case DLL_THREAD_ATTACH:
|
case DLL_THREAD_ATTACH:
|
||||||
if (user_data->threadinterface)
|
if (user_data->threadinterface)
|
||||||
{
|
{
|
||||||
if ( !TlsSetValue(user_data->threadinterface->reent_index,
|
if (!TlsSetValue(user_data->threadinterface->reent_index,
|
||||||
&user_data->threadinterface->reents))
|
&user_data->threadinterface->reents))
|
||||||
api_fatal("Sig proc MT init failed\n");
|
api_fatal("Sig proc MT init failed\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,8 +178,8 @@ search_for (uid_t uid, const char *name)
|
||||||
/* Return default passwd entry if passwd is emulated or it's a
|
/* Return default passwd entry if passwd is emulated or it's a
|
||||||
request for the current user. */
|
request for the current user. */
|
||||||
if (passwd_state != loaded
|
if (passwd_state != loaded
|
||||||
|| (! name && uid == myself->uid)
|
|| (!name && uid == myself->uid)
|
||||||
|| ( name && strcasematch(name, myself->username)))
|
|| (name && strcasematch(name, myself->username)))
|
||||||
return default_pw;
|
return default_pw;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -2436,6 +2436,13 @@ int
|
||||||
readlink (const char *path, char *buf, int buflen)
|
readlink (const char *path, char *buf, int buflen)
|
||||||
{
|
{
|
||||||
extern suffix_info stat_suffixes[];
|
extern suffix_info stat_suffixes[];
|
||||||
|
|
||||||
|
if (buflen < 0)
|
||||||
|
{
|
||||||
|
set_errno (ENAMETOOLONG);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
path_conv pathbuf (path, PC_SYM_CONTENTS, stat_suffixes);
|
path_conv pathbuf (path, PC_SYM_CONTENTS, stat_suffixes);
|
||||||
|
|
||||||
if (pathbuf.error)
|
if (pathbuf.error)
|
||||||
|
@ -2452,14 +2459,8 @@ readlink (const char *path, char *buf, int buflen)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = strlen (pathbuf.get_win32 ());
|
int len = max (buflen, (int) strlen (pathbuf.get_win32 ()));
|
||||||
if (len > (buflen - 1))
|
|
||||||
{
|
|
||||||
set_errno (ENAMETOOLONG);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
memcpy (buf, pathbuf.get_win32 (), len);
|
memcpy (buf, pathbuf.get_win32 (), len);
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
/* errno set by symlink.check if error */
|
/* errno set by symlink.check if error */
|
||||||
return len;
|
return len;
|
||||||
|
|
|
@ -96,7 +96,7 @@ struct sigaction&
|
||||||
_pinfo::getsig(int sig)
|
_pinfo::getsig(int sig)
|
||||||
{
|
{
|
||||||
#ifdef _MT_SAFE
|
#ifdef _MT_SAFE
|
||||||
if ( thread2signal )
|
if (thread2signal)
|
||||||
return thread2signal->sigs[sig];
|
return thread2signal->sigs[sig];
|
||||||
return sigs[sig];
|
return sigs[sig];
|
||||||
#else
|
#else
|
||||||
|
@ -108,7 +108,7 @@ sigset_t&
|
||||||
_pinfo::getsigmask ()
|
_pinfo::getsigmask ()
|
||||||
{
|
{
|
||||||
#ifdef _MT_SAFE
|
#ifdef _MT_SAFE
|
||||||
if ( thread2signal )
|
if (thread2signal)
|
||||||
return *thread2signal->sigmask;
|
return *thread2signal->sigmask;
|
||||||
return sig_mask;
|
return sig_mask;
|
||||||
#else
|
#else
|
||||||
|
@ -120,7 +120,7 @@ void
|
||||||
_pinfo::setsigmask (sigset_t _mask)
|
_pinfo::setsigmask (sigset_t _mask)
|
||||||
{
|
{
|
||||||
#ifdef _MT_SAFE
|
#ifdef _MT_SAFE
|
||||||
if ( thread2signal )
|
if (thread2signal)
|
||||||
*(thread2signal->sigmask) = _mask;
|
*(thread2signal->sigmask) = _mask;
|
||||||
sig_mask=_mask;
|
sig_mask=_mask;
|
||||||
#else
|
#else
|
||||||
|
@ -132,7 +132,7 @@ LONG *
|
||||||
_pinfo::getsigtodo(int sig)
|
_pinfo::getsigtodo(int sig)
|
||||||
{
|
{
|
||||||
#ifdef _MT_SAFE
|
#ifdef _MT_SAFE
|
||||||
if ( thread2signal )
|
if (thread2signal)
|
||||||
return thread2signal->sigtodo + __SIGOFFSET + sig;
|
return thread2signal->sigtodo + __SIGOFFSET + sig;
|
||||||
return _sigtodo + __SIGOFFSET + sig;
|
return _sigtodo + __SIGOFFSET + sig;
|
||||||
#else
|
#else
|
||||||
|
@ -146,7 +146,7 @@ HANDLE
|
||||||
_pinfo::getthread2signal()
|
_pinfo::getthread2signal()
|
||||||
{
|
{
|
||||||
#ifdef _MT_SAFE
|
#ifdef _MT_SAFE
|
||||||
if ( thread2signal )
|
if (thread2signal)
|
||||||
return thread2signal->win32_obj_id;
|
return thread2signal->win32_obj_id;
|
||||||
return hMainThread;
|
return hMainThread;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -29,7 +29,7 @@ make_pipe (int fildes[2], unsigned int psize, int mode)
|
||||||
if ((fdr = fdtab.find_unused_handle ()) < 0)
|
if ((fdr = fdtab.find_unused_handle ()) < 0)
|
||||||
set_errno (ENMFILE);
|
set_errno (ENMFILE);
|
||||||
else if ((fdw = fdtab.find_unused_handle (fdr + 1)) < 0)
|
else if ((fdw = fdtab.find_unused_handle (fdr + 1)) < 0)
|
||||||
set_errno ( ENMFILE);
|
set_errno (ENMFILE);
|
||||||
else if (!CreatePipe (&r, &w, sa, psize))
|
else if (!CreatePipe (&r, &w, sa, psize))
|
||||||
__seterrno ();
|
__seterrno ();
|
||||||
else
|
else
|
||||||
|
|
|
@ -137,7 +137,7 @@ pthread_self ()
|
||||||
int
|
int
|
||||||
pthread_equal (pthread_t t1, pthread_t t2)
|
pthread_equal (pthread_t t1, pthread_t t2)
|
||||||
{
|
{
|
||||||
return __pthread_equal ( &t1, &t2);
|
return __pthread_equal (&t1, &t2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mutexes */
|
/* Mutexes */
|
||||||
|
|
|
@ -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));
|
ciresrv.moreinfo->environ = (char **) cmalloc (HEAP_ARGV, envsize (envp, 1));
|
||||||
char **c;
|
char **c;
|
||||||
const char * const *e;
|
const char * const *e;
|
||||||
for (c = ciresrv.moreinfo->environ, e = envp; *e; )
|
for (c = ciresrv.moreinfo->environ, e = envp; *e;)
|
||||||
*c++ = cstrdup (*e++);
|
*c++ = cstrdup (*e++);
|
||||||
*c = NULL;
|
*c = NULL;
|
||||||
if (mode != _P_OVERLAY ||
|
if (mode != _P_OVERLAY ||
|
||||||
|
|
|
@ -601,8 +601,7 @@ _link (const char *a, const char *b)
|
||||||
&dwBytesWritten,
|
&dwBytesWritten,
|
||||||
TRUE, // abort
|
TRUE, // abort
|
||||||
FALSE, // don't process security
|
FALSE, // don't process security
|
||||||
&lpContext
|
&lpContext);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
syscall_printf ("cannot write streamId, %E");
|
syscall_printf ("cannot write streamId, %E");
|
||||||
|
@ -1635,7 +1634,7 @@ get_osfhandle (int fd)
|
||||||
|
|
||||||
if (fdtab.not_open (fd))
|
if (fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno ( EBADF);
|
set_errno (EBADF);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@ tcsendbreak (int fd, int duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
syscall_printf ("%d = tcsendbreak (%d, %d )", res, fd, duration);
|
syscall_printf ("%d = tcsendbreak (%d, %d)", res, fd, duration);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,13 +241,13 @@ MTinterface::SetItem (int _index, MTitem * _item, MTList * _list)
|
||||||
int
|
int
|
||||||
CmpPthreadObj (void *_i, void *_value)
|
CmpPthreadObj (void *_i, void *_value)
|
||||||
{
|
{
|
||||||
return ( (MTitem *) _i)->Id () == * (int *) _value;
|
return ((MTitem *) _i)->Id () == *(int *) _value;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
CmpThreadId (void *_i, void *_id)
|
CmpThreadId (void *_i, void *_id)
|
||||||
{
|
{
|
||||||
return ( (ThreadItem *) _i)->thread_id == * (DWORD *) _id;
|
return ((ThreadItem *) _i)->thread_id == * (DWORD *) _id;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue