pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/graphics/xbmbrowser Prefer the POSIX NAME_MAX over MAX...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ea80b4388b17
branches:  trunk
changeset: 515163:ea80b4388b17
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Mon Jun 26 16:11:43 2006 +0000

description:
Prefer the POSIX NAME_MAX over MAXNAMLEN when available. Try a bit
harder to avoid stack overflows, bump revision for that.

diffstat:

 graphics/xbmbrowser/Makefile         |   4 +-
 graphics/xbmbrowser/distinfo         |   6 ++-
 graphics/xbmbrowser/patches/patch-ab |  53 ++++++++++++++++++++++++
 graphics/xbmbrowser/patches/patch-ac |  32 ++++++++++++++
 graphics/xbmbrowser/patches/patch-ad |  44 ++++++++++++++++++++
 graphics/xbmbrowser/patches/patch-ae |  77 ++++++++++++++++++++++++++++++++++++
 6 files changed, 213 insertions(+), 3 deletions(-)

diffs (251 lines):

diff -r 5a86438127db -r ea80b4388b17 graphics/xbmbrowser/Makefile
--- a/graphics/xbmbrowser/Makefile      Mon Jun 26 15:24:34 2006 +0000
+++ b/graphics/xbmbrowser/Makefile      Mon Jun 26 16:11:43 2006 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.24 2006/03/04 21:29:52 jlam Exp $
+# $NetBSD: Makefile,v 1.25 2006/06/26 16:11:43 joerg Exp $
 
 DISTNAME=              xbmbrowser5.1
 PKGNAME=               xbmbrowser-5.1
-PKGREVISION=           2
+PKGREVISION=           3
 CATEGORIES=            graphics
 MASTER_SITES=          ${MASTER_SITE_XCONTRIB:=utilities/}
 
diff -r 5a86438127db -r ea80b4388b17 graphics/xbmbrowser/distinfo
--- a/graphics/xbmbrowser/distinfo      Mon Jun 26 15:24:34 2006 +0000
+++ b/graphics/xbmbrowser/distinfo      Mon Jun 26 16:11:43 2006 +0000
@@ -1,6 +1,10 @@
-$NetBSD: distinfo,v 1.5 2005/02/24 08:45:14 agc Exp $
+$NetBSD: distinfo,v 1.6 2006/06/26 16:11:43 joerg Exp $
 
 SHA1 (xbmbrowser5.1.tar.gz) = b7e6ed6509fbf985dc4348cb45c67047cd5e87dc
 RMD160 (xbmbrowser5.1.tar.gz) = 12334c23e95c19f13811315ce8ad522126d86e6e
 Size (xbmbrowser5.1.tar.gz) = 74397 bytes
 SHA1 (patch-aa) = 1c1087555ca33e3319810b8f66cf510b047f8233
+SHA1 (patch-ab) = cc7e87ea599664f94ff8c791efb3d4820197cc45
+SHA1 (patch-ac) = e78c96437e4dbf41f064983fe0a96a08bf3a67f6
+SHA1 (patch-ad) = 335297bb9c7df40007118e162e0624214d249677
+SHA1 (patch-ae) = 51b95dde72bcb95b426401458088750eb026cc43
diff -r 5a86438127db -r ea80b4388b17 graphics/xbmbrowser/patches/patch-ab
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/xbmbrowser/patches/patch-ab      Mon Jun 26 16:11:43 2006 +0000
@@ -0,0 +1,53 @@
+$NetBSD: patch-ab,v 1.1 2006/06/26 16:11:43 joerg Exp $
+
+--- xbmbrowser.h.orig  2006-06-26 15:27:35.000000000 +0000
++++ xbmbrowser.h
+@@ -27,6 +27,7 @@
+ #include <stdio.h>             /* C library includes */
+ #include <dirent.h>            /* Filename length (and dir functions) */
+ #include <assert.h>            /* debugging assertions */
++#include <limits.h>
+ 
+ #include <X11/Xaw/Form.h>      /* widget includes */
+ #include <X11/Xaw/Box.h>
+@@ -82,8 +83,13 @@ enum FileType {
+ /* item structure */
+ typedef struct _item {
+   struct _item     *next;               /* next item */
++#ifdef NAME_MAX
++  char              fname[NAME_MAX];   /* This files name in current dir */
++  char              info[NAME_MAX+40]; /* information to display about icon */
++#else
+   char              fname[MAXNAMLEN];   /* This files name in current dir */
+   char              info[MAXNAMLEN+40]; /* information to display about icon */
++#endif
+   time_t            mtime;              /* last modification time */
+   enum FileType     type;               /* file type */
+   Boolean           visible;            /* visible to user? */
+@@ -167,6 +173,18 @@ ext Widget     menu_bitmap, menu_pixmap;
+ ext Widget     menu_directory, menu_other;
+ 
+ /* substitution strings for function argument macro substitions */
++#ifdef NAME_MAX
++ext char     dir_name[NAME_MAX];     /* %d the current directory */
++ext char     file_name[NAME_MAX];    /* %f current filename */
++ext char     base_name[NAME_MAX];    /* %b basename for current file */
++ext char     suffix[NAME_MAX];       /* %s suffix of current file */
++ext char     input[NAME_MAX];        /* %i input string from user */
++ext char     home_dir[NAME_MAX];     /* %h the users home directory */
++ext char     init_dir[NAME_MAX];     /* %D initial startup directory */
++
++/* Information strings for display in application label */
++ext char     label_info[NAME_MAX];   /* label to show when outside bitmap */
++#else
+ ext char     dir_name[MAXNAMLEN];     /* %d the current directory */
+ ext char     file_name[MAXNAMLEN];    /* %f current filename */
+ ext char     base_name[MAXNAMLEN];    /* %b basename for current file */
+@@ -177,6 +195,7 @@ ext char     init_dir[MAXNAMLEN];     /*
+ 
+ /* Information strings for display in application label */
+ ext char     label_info[MAXNAMLEN];   /* label to show when outside bitmap */
++#endif
+ ext Item    *current_item;            /* which item the user is pointing to */
+ 
+ /* some external variables */
diff -r 5a86438127db -r ea80b4388b17 graphics/xbmbrowser/patches/patch-ac
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/xbmbrowser/patches/patch-ac      Mon Jun 26 16:11:43 2006 +0000
@@ -0,0 +1,32 @@
+$NetBSD: patch-ac,v 1.1 2006/06/26 16:11:43 joerg Exp $
+
+--- misc.c.orig        2006-06-26 15:29:28.000000000 +0000
++++ misc.c
+@@ -181,9 +181,15 @@ read_dir(dir)
+     last_link = &(item->next);
+     count++;
+ 
++#ifdef NAME_MAX
++    if( subdir )
++      strncpy(item->fname, dir, NAME_MAX);
++    strncat(item->fname, dp->d_name, NAME_MAX);
++#else
+     if( subdir )
+       strncpy(item->fname, dir, MAXNAMLEN);
+     strncat(item->fname, dp->d_name, MAXNAMLEN);
++#endif
+ 
+     stat(item->fname, &info);  /* discover information about this file */
+ 
+@@ -195,7 +201,11 @@ read_dir(dir)
+     if( S_ISDIR(info.st_mode) ) {      /* IF directory -- check if sym-link */
+       lstat(item->fname, &info);
+       item->type = ( S_ISLNK(info.st_mode) ? DirLink : Dir );
++#ifdef NAME_MAX
++      strncat(item->fname, "/", NAME_MAX);     /* append `/' to dir name */
++#else
+       strncat(item->fname, "/", MAXNAMLEN);     /* append `/' to dir name */
++#endif
+       if( app_data.recursive )                  /* do recursion if needed */
+         if( ! read_dir( item->fname ) )
+           item->type = DirBad;
diff -r 5a86438127db -r ea80b4388b17 graphics/xbmbrowser/patches/patch-ad
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/xbmbrowser/patches/patch-ad      Mon Jun 26 16:11:43 2006 +0000
@@ -0,0 +1,44 @@
+$NetBSD: patch-ad,v 1.1 2006/06/26 16:11:43 joerg Exp $
+
+--- xbmbrowser.c.orig  2006-06-26 15:30:08.000000000 +0000
++++ xbmbrowser.c
+@@ -279,7 +279,11 @@ main(argc, argv)
+   { extern char *getenv();
+     (void) strcpy(home_dir, getenv("HOME"));
+     if( strcmp(home_dir,"/") != 0 )
++#ifdef NAME_MAX
++      (void) strncat(home_dir, "/", NAME_MAX);
++#else
+       (void) strncat(home_dir, "/", MAXNAMLEN);
++#endif
+   }
+ 
+   /* Initialize other substitution strings */
+@@ -314,7 +318,11 @@ main(argc, argv)
+   /* Initialize user menus from the appropiate RC file */
+   /* Do this before we chdir() into some other directory */
+   { FILE *rc;
++#ifdef NAME_MAX
++    char rcfile[NAME_MAX];
++#else
+     char rcfile[MAXNAMLEN];
++#endif
+ 
+      menu_global = menu_bitmap = menu_pixmap =
+         menu_directory = menu_other = NULL;
+@@ -358,9 +366,15 @@ main(argc, argv)
+     fprintf(stderr,"xbmbrowser: couldn't chdir to '%s'\n",argv[1]);
+     exit(-1);
+   }
++#ifdef NAME_MAX
++  (void) getcwd(dir_name, NAME_MAX);
++  if( strcmp(dir_name,"/") != 0 )
++    (void) strncat(dir_name, "/", NAME_MAX);
++#else
+   (void) getcwd(dir_name, MAXNAMLEN);
+   if( strcmp(dir_name,"/") != 0 )
+     (void) strncat(dir_name, "/", MAXNAMLEN);
++#endif
+ 
+   /* copy this as the initial startup directory */
+   strcpy(init_dir, dir_name);
diff -r 5a86438127db -r ea80b4388b17 graphics/xbmbrowser/patches/patch-ae
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/xbmbrowser/patches/patch-ae      Mon Jun 26 16:11:43 2006 +0000
@@ -0,0 +1,77 @@
+$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 ~ */



Home | Main Index | Thread Index | Old Index