g_Ctoc() conversion buffers are smaller than needed up to MB_CUR_MAX - 1
since whole conversion needs a room for (len >= MB_CUR_MAX). It is no difference when MB_CUR_MAX == 1, but for multi-byte locales last few chars ('\0' and before) may need just one byte, and the rest of MB_CUR_MAX - 1 space becomes unavailable in the MAXPATHLEN-sized buffer, which cause conversion error on near MAXPATHLEN long pathes. Increase g_Ctoc() conversion buffers to MB_LEN_MAX - 1.
This commit is contained in:
parent
2c47439b3f
commit
da55f3b42c
@ -702,7 +702,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
|
|||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
int err;
|
int err;
|
||||||
char buf[MAXPATHLEN];
|
char buf[MAXPATHLEN + MB_LEN_MAX - 1];
|
||||||
|
|
||||||
struct dirent *(*readdirfunc)(DIR *);
|
struct dirent *(*readdirfunc)(DIR *);
|
||||||
|
|
||||||
@ -933,7 +933,7 @@ globfree(glob_t *pglob)
|
|||||||
static DIR *
|
static DIR *
|
||||||
g_opendir(Char *str, glob_t *pglob)
|
g_opendir(Char *str, glob_t *pglob)
|
||||||
{
|
{
|
||||||
char buf[MAXPATHLEN];
|
char buf[MAXPATHLEN + MB_LEN_MAX - 1];
|
||||||
|
|
||||||
if (*str == EOS)
|
if (*str == EOS)
|
||||||
strcpy(buf, ".");
|
strcpy(buf, ".");
|
||||||
@ -953,7 +953,7 @@ g_opendir(Char *str, glob_t *pglob)
|
|||||||
static int
|
static int
|
||||||
g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
|
g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
|
||||||
{
|
{
|
||||||
char buf[MAXPATHLEN];
|
char buf[MAXPATHLEN + MB_LEN_MAX - 1];
|
||||||
|
|
||||||
if (g_Ctoc(fn, buf, sizeof(buf))) {
|
if (g_Ctoc(fn, buf, sizeof(buf))) {
|
||||||
errno = ENAMETOOLONG;
|
errno = ENAMETOOLONG;
|
||||||
@ -967,7 +967,7 @@ g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
|
|||||||
static int
|
static int
|
||||||
g_stat(Char *fn, struct stat *sb, glob_t *pglob)
|
g_stat(Char *fn, struct stat *sb, glob_t *pglob)
|
||||||
{
|
{
|
||||||
char buf[MAXPATHLEN];
|
char buf[MAXPATHLEN + MB_LEN_MAX - 1];
|
||||||
|
|
||||||
if (g_Ctoc(fn, buf, sizeof(buf))) {
|
if (g_Ctoc(fn, buf, sizeof(buf))) {
|
||||||
errno = ENAMETOOLONG;
|
errno = ENAMETOOLONG;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user