MAXPATHLEN -> PATH_MAX

Don't assume MAXHOSTNAMELEN includes the NUL
Correct a diagnostic
Use "localhost" in our prompt instead of ""
This commit is contained in:
Brian Somers 2001-03-08 23:51:50 +00:00
parent 22dfb9bdb7
commit 5284761414
9 changed files with 16 additions and 16 deletions

View File

@ -645,7 +645,7 @@ void
bundle_LockTun(struct bundle *bundle) bundle_LockTun(struct bundle *bundle)
{ {
FILE *lockfile; FILE *lockfile;
char pidfile[MAXPATHLEN]; char pidfile[PATH_MAX];
snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit); snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit);
lockfile = ID0fopen(pidfile, "w"); lockfile = ID0fopen(pidfile, "w");
@ -663,7 +663,7 @@ bundle_LockTun(struct bundle *bundle)
static void static void
bundle_UnlockTun(struct bundle *bundle) bundle_UnlockTun(struct bundle *bundle)
{ {
char pidfile[MAXPATHLEN]; char pidfile[PATH_MAX];
snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit); snprintf(pidfile, sizeof pidfile, "%stun%d.pid", _PATH_VARRUN, bundle->unit);
ID0unlink(pidfile); ID0unlink(pidfile);

View File

@ -471,8 +471,8 @@ ip_LogDNS(const struct udphdr *uh, const char *direction)
n = name; n = name;
end = ptr + len - 4; end = ptr + len - 4;
if (end - ptr > MAXHOSTNAMELEN) if (end - ptr >= sizeof name)
end = ptr + MAXHOSTNAMELEN; end = ptr + sizeof name - 1;
while (ptr < end) { while (ptr < end) {
len = *ptr++; len = *ptr++;
if (len > end - ptr) if (len > end - ptr)

View File

@ -541,7 +541,7 @@ ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l,
const struct fsm_parent *parent) const struct fsm_parent *parent)
{ {
struct hostent *hp; struct hostent *hp;
char name[MAXHOSTNAMELEN]; char name[MAXHOSTNAMELEN + 1];
static const char * const timer_names[] = static const char * const timer_names[] =
{"IPCP restart", "IPCP openmode", "IPCP stopped"}; {"IPCP restart", "IPCP openmode", "IPCP stopped"};

View File

@ -321,17 +321,17 @@ physical_Lock(struct physical *p)
static void static void
physical_Unlock(struct physical *p) physical_Unlock(struct physical *p)
{ {
char fn[MAXPATHLEN];
if (*p->name.full == '/' && p->type != PHYS_DIRECT && if (*p->name.full == '/' && p->type != PHYS_DIRECT &&
ID0uu_unlock(p->name.base) == -1) ID0uu_unlock(p->name.base) == -1)
log_Printf(LogALERT, "%s: Can't uu_unlock %s\n", p->link.name, fn); log_Printf(LogALERT, "%s: Can't uu_unlock %s\n", p->link.name,
p->name.base);
} }
void void
physical_Close(struct physical *p) physical_Close(struct physical *p)
{ {
int newsid; int newsid;
char fn[MAXPATHLEN]; char fn[PATH_MAX];
if (p->fd < 0) if (p->fd < 0)
return; return;
@ -957,7 +957,7 @@ static void
physical_Found(struct physical *p) physical_Found(struct physical *p)
{ {
FILE *lockfile; FILE *lockfile;
char fn[MAXPATHLEN]; char fn[PATH_MAX];
if (*p->name.full == '/') { if (*p->name.full == '/') {
snprintf(fn, sizeof fn, "%s%s.if", _PATH_VARRUN, p->name.base); snprintf(fn, sizeof fn, "%s%s.if", _PATH_VARRUN, p->name.base);

View File

@ -79,7 +79,7 @@ static void
prompt_Display(struct prompt *p) prompt_Display(struct prompt *p)
{ {
/* XXX: See Index2Nam() - should we only figure this out once ? */ /* XXX: See Index2Nam() - should we only figure this out once ? */
static char shostname[MAXHOSTNAMELEN]; static char shostname[MAXHOSTNAMELEN + 1];
const char *pconnect, *pauth; const char *pconnect, *pauth;
if (p->TermMode || !p->needprompt) if (p->TermMode || !p->needprompt)
@ -109,7 +109,7 @@ prompt_Display(struct prompt *p)
if (*shostname == '\0') { if (*shostname == '\0') {
char *dot; char *dot;
if (gethostname(shostname, sizeof shostname)) if (gethostname(shostname, sizeof shostname) || *shostname == '\0')
strcpy(shostname, "localhost"); strcpy(shostname, "localhost");
else if ((dot = strchr(shostname, '.'))) else if ((dot = strchr(shostname, '.')))
*dot = '\0'; *dot = '\0';

View File

@ -373,7 +373,7 @@ radius_Authenticate(struct radius *r, struct authinfo *authp, const char *name,
struct ttyent *ttyp; struct ttyent *ttyp;
struct timeval tv; struct timeval tv;
int got, slot; int got, slot;
char hostname[MAXHOSTNAMELEN]; char hostname[MAXHOSTNAMELEN + 1];
struct hostent *hp; struct hostent *hp;
struct in_addr hostaddr; struct in_addr hostaddr;
@ -493,7 +493,7 @@ radius_Account(struct radius *r, struct radacct *ac, struct datalink *dl,
struct ttyent *ttyp; struct ttyent *ttyp;
struct timeval tv; struct timeval tv;
int got, slot; int got, slot;
char hostname[MAXHOSTNAMELEN]; char hostname[MAXHOSTNAMELEN + 1];
struct hostent *hp; struct hostent *hp;
struct in_addr hostaddr; struct in_addr hostaddr;

View File

@ -41,7 +41,7 @@ struct radius {
unsigned long mtu; /* FRAMED MTU */ unsigned long mtu; /* FRAMED MTU */
struct sticky_route *routes; /* FRAMED Routes */ struct sticky_route *routes; /* FRAMED Routes */
struct { struct {
char file[MAXPATHLEN]; /* Radius config file */ char file[PATH_MAX]; /* Radius config file */
} cfg; } cfg;
}; };

View File

@ -35,7 +35,7 @@ struct server {
struct { struct {
char passwd[50]; char passwd[50];
char sockname[MAXPATHLEN]; /* Points to local socket path */ char sockname[PATH_MAX]; /* Points to local socket path */
mode_t mask; mode_t mask;
u_short port; /* tcp socket */ u_short port; /* tcp socket */

View File

@ -313,7 +313,7 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
char *cp; char *cp;
int n, len; int n, len;
char line[LINE_LEN]; char line[LINE_LEN];
char filename[MAXPATHLEN]; char filename[PATH_MAX];
int linenum; int linenum;
int argc; int argc;
char *argv[MAXARGS]; char *argv[MAXARGS];