* fhandler_registry.cc: Use NAME_MAX + 1 instead of CYG_MAX_PATH

throughout for subkey name buffer size.
	* fhandler_socket.cc (search_wsa_event_slot): Use MAX_PATH instead of
	CYG_MAX_PATH for mutext name buffer size.
	(fhandler_socket::init_events): Ditto.
	* fhandler_virtual.cc (fhandler_virtual::opendir): Check path length
	against PATH_MAX instead of against CYG_MAX_PATH.
	* registry.cc (get_registry_hive_path): Use PATH_MAX instead of
	CYG_MAX_PATH for registry value path buffer size.
	* shared.cc (open_shared): Use MAX_PATH instead of CYG_MAX_PATH
	for shared memory name buffer size.
	* thread.cc (semaphore::semaphore): Use MAX_PATH instead of CYG_MAX_PATH
	for semaphore name buffer size.
	* uinfo.cc (cygheap_user::env_userprofile): Use PATH_MAX instead of
	CYG_MAX_PATH for temporary path name buffer size.
	* winf.h (LINE_BUF_CHUNK): Define as MAX_PATH * 2.
	* include/sys/dirent.h: Include sys/limits.h.  Define name buffer sizes
	using NAME_MAX.
This commit is contained in:
Corinna Vinschen 2007-12-05 15:10:20 +00:00
parent 8c7c7178c7
commit 5224a7bbf3
10 changed files with 44 additions and 22 deletions

View File

@ -1,3 +1,24 @@
2007-12-05 Corinna Vinschen <corinna@vinschen.de>
* fhandler_registry.cc: Use NAME_MAX + 1 instead of CYG_MAX_PATH
throughout for subkey name buffer size.
* fhandler_socket.cc (search_wsa_event_slot): Use MAX_PATH instead of
CYG_MAX_PATH for mutext name buffer size.
(fhandler_socket::init_events): Ditto.
* fhandler_virtual.cc (fhandler_virtual::opendir): Check path length
against PATH_MAX instead of against CYG_MAX_PATH.
* registry.cc (get_registry_hive_path): Use PATH_MAX instead of
CYG_MAX_PATH for registry value path buffer size.
* shared.cc (open_shared): Use MAX_PATH instead of CYG_MAX_PATH
for shared memory name buffer size.
* thread.cc (semaphore::semaphore): Use MAX_PATH instead of CYG_MAX_PATH
for semaphore name buffer size.
* uinfo.cc (cygheap_user::env_userprofile): Use PATH_MAX instead of
CYG_MAX_PATH for temporary path name buffer size.
* winf.h (LINE_BUF_CHUNK): Define as MAX_PATH * 2.
* include/sys/dirent.h: Include sys/limits.h. Define name buffer sizes
using NAME_MAX.
2007-12-04 Corinna Vinschen <corinna@vinschen.de>
* fhandler_fifo.cc (fhandler_fifo::open): Use MAX_NAME for pipe name

View File

@ -94,7 +94,7 @@ int
fhandler_registry::exists ()
{
int file_type = 0, index = 0, pathlen;
DWORD buf_size = CYG_MAX_PATH;
DWORD buf_size = NAME_MAX + 1;
LONG error;
char buf[buf_size];
const char *file;
@ -141,7 +141,7 @@ fhandler_registry::exists ()
while (ERROR_SUCCESS ==
(error = RegEnumKeyEx (hKey, index++, buf, &buf_size, NULL, NULL,
NULL, NULL))
NULL, NULL))
|| (error == ERROR_MORE_DATA))
{
if (pathmatch (buf, file))
@ -149,7 +149,7 @@ fhandler_registry::exists ()
file_type = 1;
goto out;
}
buf_size = CYG_MAX_PATH;
buf_size = NAME_MAX + 1;
}
if (error != ERROR_NO_MORE_ITEMS)
{
@ -157,7 +157,7 @@ fhandler_registry::exists ()
goto out;
}
index = 0;
buf_size = CYG_MAX_PATH;
buf_size = NAME_MAX + 1;
while (ERROR_SUCCESS ==
(error = RegEnumValue (hKey, index++, buf, &buf_size, NULL, NULL,
NULL, NULL))
@ -169,7 +169,7 @@ fhandler_registry::exists ()
file_type = -1;
goto out;
}
buf_size = CYG_MAX_PATH;
buf_size = NAME_MAX + 1;
}
if (error != ERROR_NO_MORE_ITEMS)
{
@ -302,7 +302,7 @@ fhandler_registry::fstat (struct __stat64 *buf)
int
fhandler_registry::readdir (DIR *dir, dirent *de)
{
DWORD buf_size = CYG_MAX_PATH;
DWORD buf_size = NAME_MAX + 1;
char buf[buf_size];
HANDLE handle;
const char *path = dir->__d_dirname + proc_len + 1 + prefix_len;
@ -349,7 +349,7 @@ retry:
{
/* If we're finished with sub-keys, start on values under this key. */
dir->__d_position |= REG_ENUM_VALUES_MASK;
buf_size = CYG_MAX_PATH;
buf_size = NAME_MAX + 1;
goto retry;
}
if (error != ERROR_SUCCESS && error != ERROR_MORE_DATA)
@ -628,7 +628,7 @@ fhandler_registry::fill_filebuf ()
}
return true;
value_not_found:
DWORD buf_size = CYG_MAX_PATH;
DWORD buf_size = NAME_MAX + 1;
char buf[buf_size];
int index = 0;
while (ERROR_SUCCESS ==
@ -640,7 +640,7 @@ value_not_found:
set_errno (EISDIR);
return false;
}
buf_size = CYG_MAX_PATH;
buf_size = NAME_MAX + 1;
}
if (error != ERROR_NO_MORE_ITEMS)
{
@ -658,7 +658,7 @@ open_key (const char *name, REGSAM access, DWORD wow64, bool isValue)
HKEY hKey = (HKEY) INVALID_HANDLE_VALUE;
HKEY hParentKey = (HKEY) INVALID_HANDLE_VALUE;
bool parentOpened = false;
char component[CYG_MAX_PATH];
char component[NAME_MAX + 1];
while (*name)
{

View File

@ -421,7 +421,7 @@ static HANDLE wsa_slot_mtx;
static wsa_event *
search_wsa_event_slot (LONG new_serial_number)
{
char name[CYG_MAX_PATH], searchname[CYG_MAX_PATH];
char name[MAX_PATH], searchname[MAX_PATH];
if (!wsa_slot_mtx)
{
@ -467,7 +467,7 @@ bool
fhandler_socket::init_events ()
{
LONG new_serial_number;
char name[CYG_MAX_PATH];
char name[MAX_PATH];
DWORD err = 0;
do

View File

@ -54,7 +54,7 @@ fhandler_virtual::opendir (int fd)
if (exists () <= 0)
set_errno (ENOTDIR);
else if ((len = strlen (get_name ())) > CYG_MAX_PATH - 3)
else if ((len = strlen (get_name ())) > PATH_MAX - 3)
set_errno (ENAMETOOLONG);
else if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL)
set_errno (ENOMEM);

View File

@ -12,6 +12,7 @@
#define _SYS_DIRENT_H
#include <sys/types.h>
#include <sys/limits.h>
#define __DIRENT_VERSION 2
@ -23,7 +24,7 @@ struct dirent
__ino64_t d_ino;
__uint32_t __d_unused1;
__uint32_t __d_internal1;
char d_name[256]; /* FIXME: use NAME_MAX? */
char d_name[NAME_MAX + 1];
};
#else
struct dirent
@ -32,7 +33,7 @@ struct dirent
long d_reserved[2];
long d_fd;
ino_t d_ino;
char d_name[256];
char d_name[NAME_MAX + 1];
};
#endif
#pragma pack(pop)

View File

@ -219,13 +219,13 @@ get_registry_hive_path (const char *name, char *path)
"ProfileList\\%s", name);
if (!RegOpenKeyExA (HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hkey))
{
char buf[256];
char buf[PATH_MAX];
DWORD type, siz;
path[0] = '\0';
if (!RegQueryValueExA (hkey, "ProfileImagePath", 0, &type,
(BYTE *)buf, (siz = sizeof (buf), &siz)))
ExpandEnvironmentStringsA (buf, path, CYG_MAX_PATH);
ExpandEnvironmentStringsA (buf, path, PATH_MAX);
RegCloseKey (hkey);
if (path[0])
return path;
@ -237,7 +237,7 @@ get_registry_hive_path (const char *name, char *path)
void
load_registry_hive (const char * name)
{
char path[CYG_MAX_PATH];
char path[PATH_MAX];
HKEY hkey;
LONG ret;

View File

@ -77,7 +77,7 @@ open_shared (const char *name, int n, HANDLE& shared_h, DWORD size,
VirtualFree (addr, 0, MEM_RELEASE);
}
char map_buf[CYG_MAX_PATH];
char map_buf[MAX_PATH];
char *mapname = NULL;
if (shared_h)

View File

@ -2928,7 +2928,7 @@ semaphore::semaphore (unsigned long long shash, LUID sluid, int sfd,
luid (sluid),
sem (ssem)
{
char name[CYG_MAX_PATH];
char name[MAX_PATH];
__small_sprintf (name, "%scyg_psem/cyg%016X%08x%08x", cygheap->shared_prefix,
hash, luid.HighPart, luid.LowPart);

View File

@ -408,7 +408,7 @@ cygheap_user::env_userprofile (const char *name, size_t namelen)
if (test_uid (puserprof, name, namelen))
return puserprof;
char userprofile_env_buf[CYG_MAX_PATH];
char userprofile_env_buf[PATH_MAX];
char win_id[UNLEN + 1]; /* Large enough for SID */
cfree_and_set (puserprof, almost_null);

View File

@ -18,7 +18,7 @@ details. */
#define MAXCYGWINCMDLEN 30000
#define MAXWINCMDLEN 32767
#define LINE_BUF_CHUNK (CYG_MAX_PATH * 2)
#define LINE_BUF_CHUNK (MAX_PATH * 2)
class av
{