]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
2001-11-13 Robert Collins <rbtcollins@hotmail.com>
authorRobert Collins <rbtcollins@hotmail.com>
Tue, 13 Nov 2001 02:54:39 +0000 (02:54 +0000)
committerRobert Collins <rbtcollins@hotmail.com>
Tue, 13 Nov 2001 02:54:39 +0000 (02:54 +0000)
        * choose.cc (find_tar_ext): Only match at the end of the string.
        (getpkgbyname): Prevent NULL pointer dereference.

ChangeLog
choose.cc

index ce0450001de868bad46f38fa6235e3fd31f52611..e0b33facb35128c40ccf6bc0bc875af05356a47b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-11-13  Robert Collins  <rbtcollins@hotmail.com>
+
+       * choose.cc (find_tar_ext): Only match at the end of the string.
+       (getpkgbyname): Prevent NULL pointer dereference.
+
 2001-11-13  Robert Collins  <rbtcollins@hotmail.com>
 
        * Makefile.in (CFLAGS): Add warnings and -Werr.
index 5d039b8cb861ab9eca041993633154dd0ccfd84e..3cbf1e0da4f0a35b9efbfa7616d1d09cd1d3dc27 100644 (file)
--- a/choose.cc
+++ b/choose.cc
@@ -962,8 +962,8 @@ _view::insert_under (int linen, pick_line line)
     {
       if (lines[n].get_category () || (lines[n].get_pkg ()
                                       && strcasecmp (line.get_pkg ()->name,
-                                                     lines[n].get_pkg ()->
-                                                     name) < 0))
+                                                     lines[n].
+                                                     get_pkg ()->name) < 0))
        {
          insert_at (n, line);
          n = nlines;
@@ -1285,14 +1285,15 @@ base (const char *s)
 int
 find_tar_ext (const char *path)
 {
+  char *end = strchr (path, '\0');
   /* check in longest first order */
   char *ext = strstr (path, ".tar.bz2");
   if (ext)
-    return ext - path;
+    return (end - ext) == 8 ? ext - path : 0;
   if ((ext = strstr (path, ".tar.gz")));
-  return ext - path;
+  return (end - ext) == 7 ? ext - path : 0;
   if ((ext = strstr (path, ".tar")));
-  return ext - path;
+  return (end - ext) == 4 ? ext - path : 0;
 }
 
 /* Parse a filename into package, version, and extension components. */
@@ -1363,7 +1364,7 @@ parse_filename (const char *in_fn, fileparse & f)
 Package *
 getpkgbyname (const char *pkgname)
 {
-  for (Package * pkg = package; pkg->name; pkg++)
+  for (Package * pkg = package; pkg && pkg->name; pkg++)
     if (strcasecmp (pkg->name, pkgname) == 0)
       return pkg;
 
This page took 0.033386 seconds and 5 git commands to generate.