$NetBSD: patch-ae,v 1.1 2006/06/26 16:11:43 joerg Exp $ --- user_functs.c.orig 1995-07-23 07:13:56.000000000 +0000 +++ user_functs.c @@ -44,7 +44,11 @@ void expand_tilder(text) */ char *text; { +#ifdef NAME_MAX + static char buf[NAME_MAX]; +#else static char buf[MAXNAMLEN]; +#endif char *s, *t, *t1; struct passwd *p, *getpwnam(); @@ -60,9 +64,9 @@ void expand_tilder(text) if(*buf && (p = getpwnam(buf)) == '\0') /* find correct home */ return; /* error -- return */ t1 = *buf ? p->pw_dir : home_dir; - t = buf; - strcpy(t, t1); /* buf <- home_dir */ - strcat(t, s); /* copy rest of text into buf */ + strncpy(buf, t1, sizeof(buf) - 1); /* buf <- home_dir */ + buf[sizeof(buf) - 1] = '\0'; + strncat(buf, s, sizeof(buf) - 1 - strlen(buf)); /* copy rest of text into buf */ strcpy(text, buf); /* copy it back and return it */ } @@ -75,7 +79,17 @@ change_dir(dir) */ char *dir; { +#ifdef NAME_MAX +# if NAME_MAX < 1028 char newdir[1028]; +# else + char newdir[NAME_MAX]; +#endif +#elif MAXNAMLEN < 1028 + char newdir[1028]; +#else + char newdir[MAXNAMLEN]; +#endif strcpy(newdir, dir); /* save the given variable into a buffer */ expand_tilder(newdir); /* if a ~ string expand the tilde */ @@ -84,9 +98,15 @@ change_dir(dir) if( chdir(newdir) == 0 ) { /* if success */ /* get the full path of the new directory */ +#ifdef NAME_MAX + (void) getcwd(newdir, NAME_MAX); + if( strcmp(newdir,"/") != 0 ) + (void) strncat(newdir, "/", NAME_MAX); +#else (void) getcwd(newdir, MAXNAMLEN); if( strcmp(newdir,"/") != 0 ) (void) strncat(newdir, "/", MAXNAMLEN); +#endif /* did we actually change directory */ if( strcmp(dir_name, newdir) != 0 ) { @@ -148,8 +168,13 @@ user_ok(widget, client_data, call_data ) XtPointer client_data, call_data; { if ( user_input ) { +#ifdef NAME_MAX + strncpy(input, XawDialogGetValueString(user_dialog), NAME_MAX); + input[NAME_MAX-1] = '\0'; /* just in case */ +#else strncpy(input, XawDialogGetValueString(user_dialog), MAXNAMLEN); input[MAXNAMLEN-1] = '\0'; /* just in case */ +#endif } /* expand string is first non-space char is a ~ */