From 0307846c714477583e4e377a915829e5afe2ef38 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Fri, 1 Oct 1999 01:12:04 +0000 Subject: [PATCH] AIX does not define NAME_MAX or PATH_MAX by default. It would either need a special cpp macro like _XPG4 defined or the name buffer would need to be dynamically allocated based on pathconf(), which is undesirably complicated. Instead 255 is used as a suitably sized NAME_MAX and 1024 in place of PATH_MAX. --- lib/isc/unix/dir.c | 5 +++-- lib/isc/unix/include/isc/dir.h | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/isc/unix/dir.c b/lib/isc/unix/dir.c index f127ed0ef2..e4b6a47fc7 100644 --- a/lib/isc/unix/dir.c +++ b/lib/isc/unix/dir.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: dir.c,v 1.3 1999/09/28 03:37:36 tale Exp $ */ +/* $Id: dir.c,v 1.4 1999/10/01 01:12:04 tale Exp $ */ /* Principal Authors: DCL */ @@ -93,7 +93,8 @@ isc_dir_read(isc_dir_t *dir) { /* * Make sure that the space for the name is long enough. */ - INSIST(sizeof(dir->entry.name) > strlen(entry->d_name)); + if (sizeof(dir->entry.name) <= strlen(entry->d_name)) + return (ISC_R_UNEXPECTED); strcpy(dir->entry.name, entry->d_name); diff --git a/lib/isc/unix/include/isc/dir.h b/lib/isc/unix/include/isc/dir.h index 4017337c0a..691e7f761d 100644 --- a/lib/isc/unix/include/isc/dir.h +++ b/lib/isc/unix/include/isc/dir.h @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: dir.h,v 1.1 1999/09/23 17:31:59 tale Exp $ */ +/* $Id: dir.h,v 1.2 1999/10/01 01:12:04 tale Exp $ */ /* Principal Authors: DCL */ @@ -32,13 +32,23 @@ ISC_LANG_BEGINDECLS typedef struct { - char name[NAME_MAX]; + /* + * Ideally, this should be NAME_MAX, but AIX does not define it by + * default and dynamically allocating the space based on pathconf() + * complicates things undesirably, as does adding special conditionals + * just for AIX. So a comfortably sized buffer is chosen instead. + */ + char name[256]; unsigned int length; } isc_direntry_t; typedef struct { int magic; - char dirname[PATH_MAX]; + /* + * As with isc_direntry_t->name, making this "right" for all systems + * is slightly problematic because AIX does not define PATH_MAX. + */ + char dirname[1024]; isc_direntry_t entry; DIR * handle; } isc_dir_t;