Lines 119-126
catopen(const char *name, int type)
Link Here
|
119 |
char path[PATH_MAX]; |
119 |
char path[PATH_MAX]; |
120 |
|
120 |
|
121 |
/* sanity checking */ |
121 |
/* sanity checking */ |
122 |
if (name == NULL || *name == '\0') |
122 |
if (name == NULL) |
123 |
NLRETERR(EINVAL); |
123 |
NLRETERR(EINVAL); |
|
|
124 |
if (*name == '\0') |
125 |
NLRETERR(ENOENT); |
124 |
|
126 |
|
125 |
if (strchr(name, '/') != NULL) |
127 |
if (strchr(name, '/') != NULL) |
126 |
/* have a pathname */ |
128 |
/* have a pathname */ |
Lines 367-372
load_msgcat(const char *path, const char *name, const char *lang)
Link Here
|
367 |
struct catentry *np; |
369 |
struct catentry *np; |
368 |
void *data; |
370 |
void *data; |
369 |
int fd; |
371 |
int fd; |
|
|
372 |
int saved_errno; |
370 |
|
373 |
|
371 |
/* path/name will never be NULL here */ |
374 |
/* path/name will never be NULL here */ |
372 |
|
375 |
|
Lines 390-395
load_msgcat(const char *path, const char *name, const char *lang)
Link Here
|
390 |
} |
393 |
} |
391 |
|
394 |
|
392 |
if (_fstat(fd, &st) != 0) { |
395 |
if (_fstat(fd, &st) != 0) { |
|
|
396 |
saved_errno = errno; |
397 |
_close(fd); |
398 |
SAVEFAIL(name, lang, saved_errno); |
399 |
NLRETERR(saved_errno); |
400 |
} |
401 |
|
402 |
/* The file is too small to contain a _NLS_MAGIC. */ |
403 |
if (st.st_size < sizeof(u_int32_t)) { |
393 |
_close(fd); |
404 |
_close(fd); |
394 |
SAVEFAIL(name, lang, EFTYPE); |
405 |
SAVEFAIL(name, lang, EFTYPE); |
395 |
NLRETERR(EFTYPE); |
406 |
NLRETERR(EFTYPE); |
Lines 408-414
load_msgcat(const char *path, const char *name, const char *lang)
Link Here
|
408 |
|
419 |
|
409 |
if ((data = mmap(0, (size_t)st.st_size, PROT_READ, |
420 |
if ((data = mmap(0, (size_t)st.st_size, PROT_READ, |
410 |
MAP_FILE|MAP_SHARED, fd, (off_t)0)) == MAP_FAILED) { |
421 |
MAP_FILE|MAP_SHARED, fd, (off_t)0)) == MAP_FAILED) { |
411 |
int saved_errno = errno; |
422 |
/* |
|
|
423 |
* mmap(2) sets EINVAL when the filetype is not mappable. |
424 |
* By capturing this, we can make sure EINVAL is exported |
425 |
* iff the original name argument is NULL. |
426 |
*/ |
427 |
if (errno == EINVAL) |
428 |
saved_errno = EFTYPE; |
429 |
else |
430 |
saved_errno = errno; |
412 |
_close(fd); |
431 |
_close(fd); |
413 |
SAVEFAIL(name, lang, saved_errno); |
432 |
SAVEFAIL(name, lang, saved_errno); |
414 |
NLRETERR(saved_errno); |
433 |
NLRETERR(saved_errno); |