[tbb-commits] [tor-browser/tor-browser-45.5.0esr-6.0-1] fixup! Bug #4234: Use the Firefox Update Process for Tor Browser.

gk at torproject.org gk at torproject.org
Wed Nov 9 18:49:08 UTC 2016


commit f0382d95b8145b91bae099024bce64affff34523
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Wed Nov 9 12:02:00 2016 -0500

    fixup! Bug #4234: Use the Firefox Update Process for Tor Browser.
    
    Modify the AddSymlink implementation to use absolute paths when creating
    symlinks. This fixes a compile error that was introduced due to the changes
    Mozilla made for https://bugzilla.mozilla.org/show_bug.cgi?id=1246972.
---
 toolkit/mozapps/update/updater/updater.cpp | 47 ++++++++++++++++++------------
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp
index 9e45698..d6d0f09 100644
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -1986,9 +1986,7 @@ PatchIfFile::Finish(int status)
 class AddSymlink : public Action
 {
 public:
-  AddSymlink() : mLinkName(NULL)
-               , mTarget(NULL)
-               , mAdded(false)
+  AddSymlink() : mAdded(false)
             { }
 
   virtual int Parse(NS_tchar *line);
@@ -1997,8 +1995,9 @@ public:
   virtual void Finish(int status);
 
 private:
-  const NS_tchar *mLinkName;
-  const NS_tchar *mTarget;
+  mozilla::UniquePtr<NS_tchar[]> mLinkPath;
+  mozilla::UniquePtr<NS_tchar[]> mRelPath;
+  mozilla::UniquePtr<NS_tchar[]> mTarget;
   bool mAdded;
 };
 
@@ -2007,26 +2006,36 @@ AddSymlink::Parse(NS_tchar *line)
 {
   // format "<linkname>" "target"
 
-  mLinkName = get_valid_path(&line);
-  if (!mLinkName)
+  NS_tchar * validPath = get_valid_path(&line);
+  if (!validPath)
     return PARSE_ERROR;
 
+  mRelPath = mozilla::MakeUnique<NS_tchar[]>(MAXPATHLEN);
+  NS_tstrcpy(mRelPath.get(), validPath);
+  mLinkPath.reset(get_full_path(validPath));
+  if (!mLinkPath) {
+     return PARSE_ERROR;
+  }
+
   // consume whitespace between args
   NS_tchar *q = mstrtok(kQuote, &line);
   if (!q)
     return PARSE_ERROR;
 
-  mTarget = get_valid_path(&line, false, true);
-  if (!mTarget)
+  validPath = get_valid_path(&line, false, true);
+  if (!validPath)
     return PARSE_ERROR;
 
+  mTarget = mozilla::MakeUnique<NS_tchar[]>(MAXPATHLEN);
+  NS_tstrcpy(mTarget.get(), validPath);
+
   return OK;
 }
 
 int
 AddSymlink::Prepare()
 {
-  LOG(("PREPARE ADDSYMLINK " LOG_S " -> " LOG_S, mLinkName, mTarget));
+  LOG(("PREPARE ADDSYMLINK " LOG_S " -> " LOG_S, mRelPath.get(), mTarget.get()));
 
   return OK;
 }
@@ -2034,26 +2043,26 @@ AddSymlink::Prepare()
 int
 AddSymlink::Execute()
 {
-  LOG(("EXECUTE ADDSYMLINK " LOG_S " -> " LOG_S, mLinkName, mTarget));
+  LOG(("EXECUTE ADDSYMLINK " LOG_S " -> " LOG_S, mRelPath.get(), mTarget.get()));
 
   // First make sure that we can actually get rid of any existing file or link.
   struct stat linkInfo;
-  int rv = lstat(mLinkName, &linkInfo);
+  int rv = lstat(mLinkPath.get(), &linkInfo);
   if ((0 == rv) && !S_ISLNK(linkInfo.st_mode)) {
-    rv = NS_taccess(mLinkName, F_OK);
+    rv = NS_taccess(mLinkPath.get(), F_OK);
   }
   if (rv == 0) {
-    rv = backup_create(mLinkName);
+    rv = backup_create(mLinkPath.get());
     if (rv)
       return rv;
   } else {
-    rv = ensure_parent_dir(mLinkName);
+    rv = ensure_parent_dir(mLinkPath.get());
     if (rv)
       return rv;
   }
 
   // Create the link.
-  rv = symlink(mTarget, mLinkName);
+  rv = symlink(mTarget.get(), mLinkPath.get());
   if (!rv) {
     mAdded = true;
   }
@@ -2064,12 +2073,12 @@ AddSymlink::Execute()
 void
 AddSymlink::Finish(int status)
 {
-  LOG(("FINISH ADDSYMLINK " LOG_S " -> " LOG_S, mLinkName, mTarget));
+  LOG(("FINISH ADDSYMLINK " LOG_S " -> " LOG_S, mRelPath.get(), mTarget.get()));
   // When there is an update failure and a link has been added it is removed
   // here since there might not be a backup to replace it.
   if (status && mAdded)
-    NS_tremove(mLinkName);
-  backup_finish(mLinkName, status);
+    NS_tremove(mLinkPath.get());
+  backup_finish(mLinkPath.get(), mRelPath.get(), status);
 }
 #endif
 



More information about the tbb-commits mailing list