This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH setup] Avoid potential null deref in check_for_cached()
- From: Jon Turney <jon dot turney at dronecode dot org dot uk>
- To: cygwin-apps at cygwin dot com
- Cc: Jon Turney <jon dot turney at dronecode dot org dot uk>
- Date: Thu, 4 Oct 2018 19:42:45 +0100
- Subject: [PATCH setup] Avoid potential null deref in check_for_cached()
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