This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix a couple of null-derefs in setup.exe


    Hi gang,

  There are a couple of places where setup can bomb if you blow away your
stored settings (cached mirror list or last mirror), as it gets a null pointer
on trying to read them back; both strtok and the std::string(const char *)
ctor blow up on this.  Attached patch trivially protects against both.

	* site.cc (get_site_list): Use empty string if user settings
	return NULL pointer for cached mirrors list.
	(SiteSetting::getSavedSites): Do nothing if user settings return
	NULL pointer for last mirror URL.

  Ok?

    cheers,
      DaveK
Index: site.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/site.cc,v
retrieving revision 2.46
diff -p -u -r2.46 site.cc
--- site.cc	21 Aug 2009 04:15:01 -0000	2.46
+++ site.cc	18 Sep 2009 11:24:40 -0000
@@ -299,6 +299,7 @@ get_site_list (HINSTANCE h, HWND owner)
     {
       log (LOG_BABBLE) << "Cached mirror list unavailable" << endLog;
       cache_is_usable = false;
+      cached_mirrors = "";
     }
 
   if (LoadString (h, IDS_MIRROR_LST, mirror_url, sizeof (mirror_url)) <= 0)
@@ -369,6 +370,8 @@ void
 SiteSetting::getSavedSites ()
 {
   const char *buf = UserSettings::instance().get ("last-mirror");
+  if (!buf)
+    return;
   char *fg_ret = strdup (buf);
   for (char *site = strtok (fg_ret, "\n"); site; site = strtok (NULL, "\n"))
     registerSavedSite (site);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]