[PATCH setup] Avoid potential null deref in check_for_cached()
Jon Turney
jon.turney@dronecode.org.uk
Thu Oct 4 18:43:00 GMT 2018
Packages for which we don't know a filename can't possibly be cached.
See https://cygwin.com/ml/cygwin/2018-10/msg00033.html
---
download.cc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/download.cc b/download.cc
index 0cb3352..55c6295 100644
--- a/download.cc
+++ b/download.cc
@@ -84,9 +84,16 @@ int
check_for_cached (packagesource & pkgsource, HWND owner, bool mirror_mode,
bool check_hash)
{
+ /* If the packagesource doesn't have a filename, it can't possibly be in the
+ cache */
+ if (!pkgsource.Canonical())
+ {
+ return 0;
+ }
+
/* Note that the cache dir is represented by a mirror site of file://local_dir */
std::string prefix = "file://" + local_dir + "/";
- std::string fullname = prefix + (pkgsource.Canonical() ? pkgsource.Canonical() : "");
+ std::string fullname = prefix + pkgsource.Canonical();
if (mirror_mode)
{
--
2.17.0
More information about the Cygwin-apps
mailing list