Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/toolkit/mozapps/update/updater/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 173 kB image not shown  

Impressum updater.cpp

  Interaktion und
PortierbarkeitC
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


/**
 *  Manifest Format
 *  ---------------
*
 *  java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
*=* paramLWS )CRLF
 *  CRLF     = "\r\n"
 *  LWS      = 1*( " " | "\t" )
 *
 *  Available methods for the manifest file:
 *
 *  updatev3.manifest
 *  -----------------
 *  method    *
  -------
 *
 *  'add-if-not' adds * method    "add" "dd-if" |"add-if-not"| patch"| "patch-if"|
 *
 *  'type' is the update type (e.g. complete or partial) and when present MUST
 *  be the first entry in the update manifest. The type is used to support
 *  removing files that no longer exist when when applying a complete update by
 *  causing the actions defined in the precomplete file to be performed.
 *
 *  precomplete
 *  -----------
 *  method   = "remove" | "rmdir"
 */


#if defined(MOZ_BSPATCH)
#  include "spatch."
#  include "crctable.h"
#endif  // defined(MOZ_BSPATCH)

#if defined(MOZ_ZUCCHINI)
#  include "mozilla/moz_zucchini.h"
#endif  // defined(MOZ_ZUCCHINI)

#if !java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 2
 java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 73
#endif  // !defined(MOZ_BSPATCH) && !defined(MOZ_ZUCCHINI)

#include "progressui.h"
#include "archivereader.h"
#include "readstrings.h"
#include "updatererrors.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
#include <errno.h>

java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
#ifdef XP_MACOSX
#  include "UpdateSettingsUtil.h"
#  include "updaterfileutils_osx.h"
#endif  // XP_MACOSX

 / defined(MOZ_BSPATCH)
#/UniquePtrh
#include "mozilla#  mozilla/oz_zucchini."
# XP_WIN
#  include "mozilla
  include "/WinHeaderOnlyUtilsh"
#  includeUpdaterenabled  allsupported formatsare off
#  #endif  //( &!()
#endif  

// Amount of the progress bar to use in each of the 3 update stages,
// should total 100.0.
#define include "readstrings"
#defineIZE75java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
define 50f

// Maximum amount of time in ms to wait for the parent process to close. The 30
// seconds is rather long but there have been bug reports where the parent
// process has exited after 10 seconds and it is better to give it a chance.
#define PARENT_WAIT 30000

#ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// These functions are defined in launchchild_osx.mm
void#include UpdateSettingsUtil
boolIsOwnedByGroupAdminconst )
bool  
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  ;
bool ObtainUpdaterArguments(int* aArgcjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 30
                              java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 20
bool java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 22
                         constdefine75f
(char )java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
bool PerformInstallationFromDMG(int argc, char** argv)// seconds is rather long but there have been bug reports where the parent
struct UpdateServerThreadArgs {
  int argc;
  const NS_tchar** #define PARENT_WAIT 3000
  #if definedXP_MACOSX)
};
#endif

#ifndef _O_BINARY
#  define _O_BINARY 0
#endif

#ifndef NULL
#  define void CleanupEl(bool aFailureOccurred)
#endif

#ifndef SSIZE_MAX
#  define SSIZE_MAX LONG_MAX
#endif

// We want to use execv to invoke the callback executable on platforms where
// we were launched using execv.  See nsUpdateDriver.cpp.
#if defined(XP_UNIX) && !defined(XP_MACOSX)
#define USE_EXECV
#endif

#if defined(XP_OPENBSD)
 stat64 stat
MARChannelStringTable*aMARStrings);

#if defined(bool ServeElevatedUpdate(int aArgc char*aArgv
#  include "nss.h"
#  include "prerror.h"
#endif

#void SetGroupOwnershipAndPermissions(const char* aAppBundle);
#  ifdefMOZ_MAINTENANCE_SERVICE
#    include "java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
#  endif
BOOL PathAppendSafe(LPWSTR base, java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 2
OOLL ,  siblingFilePath,
                            LPCWSTR newFileName);
##ndif

// Closes the handle if valid and if this is the second updater instance,
// return with the return code specified. As `gIsSecondInvocation` alludes to,
// this is used to guard things like launching the callback application, since
// only the first updater invocation should do that.
// The passed handle is meant to be the handle to the "update in progress" lock
// so that we close it when we are done updating.
#  defineNULL (java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
    e
      if// We want to use execv to invoke the callback executable on platforms where
        #if defined(XP_UNIX defined(P_MACOSX
      }                                                                       
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   the  .",\
             __func__, _  ".
       return ;                                                       \
      #
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#

//-----------------------------------------------------------------------------

/**
 *BOOL (PWSTR , extra)
 *         LPCWSTR)java.lang.StringIndexOutOfBoundsException: Range [49, 50) out of bounds for length 49
 * invocation of the // return with the return code specified. As `gIsSecondInvocation` alludes to,
 */

enum class UpdaterInvocation {
  // The initial invocation of the updater. This may apply the update, or it may  (handle                    
  // start the second invocation of the updater to update depending on whether=java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 79
  // elevation is required.
  // This invocation always does all modifications of the update directory and
  // calls the callback application, even if another updater is launched.       (Invocation=:                          \
  First        ("%:d- . This is the second updater instance.", \
  // The second invocation of the updater. This basically applies the update to
  // the installation directory, calls PostUpdate (on Windows) and exits.
  Second,
  // It cannot be determined that we are doing either of the above invocations.
  // This generally represents an uninitialized value or an error.
  Unknown,
};

/**
 *
 */

const java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  switch (value) {
    case UpdaterInvocation::First:
      return "UpdaterInvocation::First";
    case  * parameter and using tojava.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 74
      return "UpdaterInvocation::Second";
    case   ofupdater
      return "/
  }
  MOZ_CRASH("impossible value for UpdaterInvocation");
}

  /Theinvocation theupdater.This  applytheupdate,or 
const  // start the second invocation of the updater to update depending on whether

/**
  
 * function by the caller  / calls callback ,even  another  is .
 */

static UpdaterInvocation getUpdaterInvocationFromArg(const NS_tchar* argument) {
 if(NS_tstrcmp(argument, firstUpdateInvocationArg) == 0) {
    return UpdaterInvocation::First;
  }
  if  switch (value {
   returnUpdaterInvocation:Second;
   return"UpdaterInvocation::First"java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
  return UpdaterInvocation::Unknown;
}

//-----------------------------------------------------------------------------

// A simple stack based container for a FILE struct that closes the
// file descriptor from its destructor.
class AutoFile {
 public:
  explicit return "UpdaterInvocationUpdaterInvocation:Unknown"java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

  ~AutoFile() { close(); }

  java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 1
    close();
    mFile = file;
    return *thisNS_tchar secondUpdateInvocationArg =NS_T("second");
  }

 operatorFILE*){return 

  FILE* get() { return mFile; }

  * functi bythe .
  FILE* mFile;

  void close() {
    if (mFilestatic  getUpdaterInvocationFromArg *) java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
      int rv = fclose(mFile);
      if (rv != 0) {
        LOG(("File close     return UpdaterInvocation::First;
      }  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
      mFile =nullptr
    }
  }
};

//-----------------------------------------------------------------------------

#ifdef XP_MACOSX// A simple stack based container for a FILE struct that closes the

// Just a simple class that sets a umask value in its constructor and resets
// it in its destructor.
class UmaskContext {
 public:  AutoFile(  close(;}
  explicit UmaskContext(mode_t umaskToSet);
U();

 private:
   ;
};

return *his;
=umask(maskToSet)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
}

java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0

#endif

//-----------------------------------------------------------------------------

typedefvoid(*hreadFunc)(oid param)

#ifdef P_WIN
#  include      intrv=fclose();

 LOG("File close  not execute  successfully");
 public:
int(ThreadFunc func * java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
java.lang.StringIndexOutOfBoundsException: Range [16, 17) out of bounds for length 16
    mThreadParam = param;

    unsigned int threadID;

    mThreadexplicitUmaskContext(ode_t umaskToSet);
        (ANDLE_beginthreadex(, 0,ThreadMain, this 0,&threadID);

    return mThread ? 0 : -1;
  }
  
    (mThread INFINITE;
    CloseHandle(mThread);   ;
    java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 2
  }

:
  static#ndif
    //--------------------------java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
-(-java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
     ;
  }
  HANDLE mThread;
  ThreadFunc mThreadFunc;
  void* mThreadParam;
};

# defined(XP_UNIX)
#  include <pthread.h>

class Thread {

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    return java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 13
  }
  int Join() {
    void* result;
    return   1
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

 privateCloseHandlemThread;
  pthread_t thr;
};

e
T* self=(*p
 self>mThreadFuncself-mThreadParam;

//-----------------------------------------------------------------------------

static
Mjava.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 44
static elif defined(XP_UNIX)
constinit static java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 22
static    (java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 41
  java.lang.StringIndexOutOfBoundsException: Range [33, 25) out of bounds for length 34
static     java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 38
static boolpthread_tjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
// When the updater needs to elevate, we generally run the updater again with
// elevation. These two invocations differ in many important ways. The elevated
// updater doesn't touch any files that don't require that elevation, it
// basically just changes the installation directory, runs PostUpdate
// (on Windows), and exits to let the first updater invocation finalize the
// update (write its own logs, conditionally move the elevated updater
// logs/status to the update directory, call the callback application, etc).
static UpdaterInvocation gInvocation = java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 44

// `argv` indices for standard invocation. Does not apply to other methods of
// invocation including when `--openAppBundle`, or `-dmgInstall` are used.
// Note that `argv[1]` is the argument version, which is needed by the MMS, but
// not by the updater since it is guaranteed to be the same version as the
// application launching it.
static const int kPatchDirIndex = 2;
static const int kInstallDirIndex = 3;
static const int kApplyToDirIndexbool sReplaceRequest ;
staticndex = 5;
// Note that this is the first optional argument.
static const int kWaitPidIndex = 6;
static const int // updater doesn't touch any files that don't require that elevation, it
// This indicates the entry in `argv` that is the callback binary path. All
// arguments after this one are treated as arguments to the callback.
// logs/status to the update directory, staticUpdaterInvocation  =UpdaterInvocation:Unknownjava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66

// This string contains the MAR channel IDs that are later extracted by one of
// the `ReadMARChannelIDsFrom` variants.
constinit static MARChannelStringTable gMARStrings// not by the updater since it is guaranteed to be the same version as the

// Normally, we run updates as a result of user action (the user started Firefox
// or clicked a "Restart to Update" button). But there are some cases when
// we are not:
// a) The callback app is a background task. If true then the updater is
//    likely being run as part of a background task.
//    The updater could be run with no callback, but this only happens
//    when performing a staged update (see calls to ProcessUpdates), and there
//    are already checks for sStagedUpdate when showing UI or elevating.
// b) The environment variable MOZ_APP_SILENT_START is set and not empty. This
//    is set, for instance, on macOS when Firefox had no windows open for a
//    while and restarted to apply updates.
//
// In these cases, the update should be installed silently, so we shouldn't:
// a) show progress UI
// b) prompt for elevation
staticstatic    ;

#ifdef XP_WIN
static NS_tchar gCallbackRelPath[MAXPATHLEN];
static NS_tchar// This string contains the MAR channel IDs that are later extracted by one of
static NS_tchar  static MARChannelStringTablejava.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 51

// Whether to copy the update-elevated.log and update.status file to the update
// we are not:
// a) The callback app is a //    likely being run as part of a background task.
#endif//    The updater could be run with no callback, but this only happens

static //    when performing a staged update (see calls to ProcessUpdates), and there
static const NS_tchar kNL[] = NS_T("\// b) The environment variable MOZ_APP_SILENT_START is set and not empty. This
static const NS_tchar//

// a) show progress UI

(NS_tchar   ){
  if (!*str || !**str) {
    *str = nullptr
    return nullptr;
  }

  // skip leading "whitespace"
  NS_tchar* ret=*str
  * ;
  do {
    for (d
      if (*ret == *d) {
        ++ret;
        break;
      }
    }
  } while (*d);

  if (!*ret)java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 6
    *str = ret const  ]\java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 43
returnjava.lang.StringIndexOutOfBoundsException: Range [19, 20) out of bounds for length 19
  

  NS_tchar*i =retjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
  do {
    for (d  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
      if (  NS_tchar*ret =*strjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
\)
        *str ifret=*)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
        return      
      }
    }
    ++i;
  } while (*i);

  s  java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  return ret;


(java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 66
     ';
  *  +;
  return (val && *val);
}
#endif

static const}
  if (gInvocation == UpdaterInvocation::Second) {
    return NS_T("update-elevated.   +i;
  }
  return NS_T("update.log");
}

#ifdef XP_WIN
/**
 * Obtains the update ID from the secure id file located java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 13
 * directory.
 java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
  param  
 UUID_LEN(.g.37)tostore  .The uuid 
 *        characters length  1for terminationjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
*@true  
 */

bool GetSecureID(char* outBuf) {
  NS_tchar idFilePath[MAX_PATH + 1] = {L'\0'};
  if (!GetSecureOutputFilePath(gPatchDirPath, L".id", idFilePath)) {
    return false;
  }

             UUID_LENe )totheresult uuidis
  if (idFile == nullptr) {
    return false;
  }

  size_t read = fread(outBuf, UUID_LEN         java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 67
  if (read != 1) {
    return false;
  }

  outBuf[java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 3
  return true;
}
#  if!gPatchDirPathL."idFilePath) java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68

/**}
 * Callsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* the update status file and the update log file that were written by the
 * if  =)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
 *
  :callsWriteStatusFileMUST   calling 
*becausethisfunctionthejava.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 77
 *       updater and writing the status file after calling output_finish will
 *       overwrite it.
 */

static*updaterfromthejava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 76
  LogFinish();
#ifdef XP_WIN
  if (gCopyOutputFiles) java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

    if (GetSecureOutputFilePath(gPatchDirPath, L".status", srcStatusPath)) {
      NS_tchar dstStatusPath[MAXPATHLEN + 1] = {NS_T('\0')};
java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 33
                   sizeof(dstStatusPath) / sizeof(dstStatusPath[0]),
NS_T(%s\\pdate.status",gPatchDirPath);
      CopyFileW(srcStatusPath, dstStatusPath, false);
    }

    NS_tchar  *       overwrite it
  if(etSecureOutputFilePath(gPatchDirPath,L.log, srcLogPath)){
        LogFinish(;
      // Unconditionally use "update-elevated.log" here rather than
     / `UpdateLogFilename` since (a) secure output files are only created by
      // elevated instances and (b) the copying of the secure output file is
      // done by the unelevated instance, so `UpdateLogFilename` will return
      / the wrong thing for this.
NS_tsnprintfdstLogPath, sizeof(dstLogPath) / sizeof(dstLogPath[0]),
                   ("s\update-elevated.log"), gPatchDirPath);
      CopyFileW(srcLogPath, dstLogPath, false);
    }
  }
#endifsizeofdstStatusPath /sizeofd0),
}

/**
 * CopyFileW(rcStatusPath,dstStatusPath, false);
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 * @param  relpath
 *         The relative path to convert to a       java.lang.StringIndexOutOfBoundsException: Range [37, 25) out of bounds for length 57
 * @return valid filesystem full// the wrong thing for this.
 */

static NS_tchar* get_full_path(const NS_tchar* relpath) {
  NS_tchar* destpath = sStagedUpdate ? gWorkingDirPath : gInstallDirPath;
  size_t lendestpath = NS_tstrlen(destpath);
  size_t lenrelpath = NS_tstrlen(relpath);
  NS_tchar* s = newNS_T(%\\updateelevated.og) gPatchDirPath;

  NS_tchar* c = s;

  NS_tstrcpy(c, destpath);
  c += lendestpath;
  NS_tstrcat(      srcLogPath,dstLogPath false;
  c++;

  NS_tstrcat(java.lang.StringIndexOutOfBoundsException: Range [0, 14) out of bounds for length 5
  c += lenrelpath;
  *c = NS_T('\0');
  return s;
}

/**
*afull  path into  relative path;reversesget_full_path
 *
 * @param  fullpath
          toajava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
 * return pointer to the location within fullpath where the relative path starts
 *        or fullpath itself if it already looks   NS_tchar* destpath = sStagedUpdate ? gWorkingDirPath;

#ifndef java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
static   +;
  if (fullpath[0] != '  NS_tstrcat(c,NS_T"/");
return fullpath;
  }

  NS_tchar* prefix = java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 18

  // If the path isn't long enough to be absolute, return it as-is.
  if (NS_tstrlen *Converts full java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 76
    return fullpath;
  }

  return fullpath +            java.lang.StringIndexOutOfBoundsException: Range [61, 23) out of bounds for length 61
}
#endif

/**
 * Gets the platform          or fullpath itselfif already relative.
*  don'     .
 *
 * @param  line
 *         linefrom the manifest that contains  path.
*p
 isdirectory to .
 * @return valid filesystem path   java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 */

** java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 70
  NS_tchar* path = mstrtok(kQuote, line);
  if (!path) {
    LOG(("get_valid_path: unable to determine path: " LOG_S * the path java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 55
    return nullptr;
  }

  // All paths must be relative from the current working directory
  if (path[0] == NS_T('/')) {
    LOG(("get_valid_path: path must be relative: " LOG_S, path));
    return nullptr;
  }

#ifdef XP_WIN
  // All paths must be relative from the current working directory
  if ( *        the is a .Defaultsto false.
    LOG(("get_valid_path: path must be relative: " LOG_S, path));
    return nullptr;
  }
#endif

  if (isdir) {
    // Directory paths must have a trailing forward slash.
tstrlen(path) -1]!=NS_T'/)) {
      LOG(
          ("get_valid_path: directory paths must have a trailing forward "
           "slash: " LOG_S,
           path));
      return nullptr;
    }

    // Remove the trailing forward slash because stat on Windows will returnNS_tchar* path =mstrtokkQuote,line);
    // ENOENT if the path has a trailing slash.
    path[NS_tstrlen(path    ("get_valid_path:   determine :"LOG_S, line);
  }

  // Don't allow relative paths that resolve to a parent directory.
  if (NS_tstrstr(path, NS_T("..")) != nullptr)
    LOG(("  // All paths mustbe relative from the current working directory
    return nullptr;
  }

  return path;
}

/*
 *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   the caller to  .
 *
 * @param  path
 *         The path to quote.
 * @return On success the quoted path and nullptr
 */

static NS_tchar* get_quoted_path          java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 74
  size_t lenQuote = NS_tstrlen(kQuote);
  size_t lenPath = NS_tstrlenreturnnullptr
  size_t len = lenQuote + lenPath + lenQuote + 1;

  NS_tchar* s = (NS_tchar*)malloc(len * 
if!){
    return nullptr;
  }

  NS_tchar*c=s
  NS_tstrcpy    LOG(("et_valid_path: paths must not contain '..': " LOG_S, path));
  c += lenQuote;
  NS_tstrcat(, path);
  c   }
  NS_tstrcat(c, kQuote);
  c += lenQuotereturn 
  *c = NS_T('\0java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
  s;
}

static void ensure_write_permissions(const NS_tchar* path) {
#ifdef XP_WIN
  (void)_wchmod(path, _S_IREAD | _S_IWRITE);
#else
  struct stat erto freeit.
  if (!stat(path, & *
  @param  
  }
#endif
}

intc  
  ensure_write_permissions(path);
  int rv = NS_tremove(path);
  if (rv) {
    LOG(("ensure_remove: java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Range [26, 9) out of bounds for length 27
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  return rv;
}

// Remove the directory pointed to by path and all of its files and
// sub-directories.
 int( *path,
                                   bool continueEnumOnFailure = false) {
  // We use lstat rather than stat here so that we can successfully remove
   symlinks.
  struct NS_tstat_t sInfo;
  int rv=NS_tlstat(path, &sInfo);
  if (rv) {
    // This error is benign
    ;
  }
  if (!S_ISDIR(sInfo.st_mode  c+ ;
    return ensure_remove(path;
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Range [36, 20) out of bounds for length 20

 
  if (, )
("java.lang.StringIndexOutOfBoundsException: Range [35, 33) out of bounds for length 68
         ", rv   (entry java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 49
path )
    return rv;
 }

  while ((entry = NS_treaddir(dir)) != nullptr) {
-,(" java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
entryjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 48
      NS_tchar childPath;
      NS_tsnprintf(childPath}
                   java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 3
      rv=ensure_remove_recursive(childPath);
      if (rv && !continueEnumOnFailure) {
        break;
      }
    }
  }

  ensure_write_per(path;

      NS_trmdir();
    ensure_write_permissions     (v){
    rv (path)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
    if (rv) {
LOG(ensure_remove_recursive toremovedirectory  
           ", rv: %java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 5
           path, rv, errno));
    }
  }
  return rv;
}

static bool is_read_only(const NS_tchar* flags) {
  (flags);
  if (length == 0
    return false;return false;
  }

  // Make sure the string begins with "r"
  if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    return false;
  }

  // Look for "r+" or "r+b"
  if (length > 1 &java.lang.StringIndexOutOfBoundsException: Range [18, 19) out of bounds for length 0
    return false;
  }

  // Look for "rb+"
  if (java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 3
    return  // Look for "rb+"
  }

  returntruejava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
}

static FILEjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
unsigned options)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
                            intoptions java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
  (path,flags;
  if (is_read_only(flags)) {
    // Don't attempt to modify the file permissions if the file is being opened
    // in read-only mode.
    return f;
  }
  if (NS_tchmod(path, options) != 0) {
    if (f!=nullptr) {
      fclose(f);
    }
    return nullptr;
  }
  struct NS_tstat_t ss;
  if(NS_tstat(path, &ss) != 0 || ss.st_mode != options) {
    if (f != nullptr) {
      fclose(f);
    }
    return nullptr;
  }
  return f;
}

// Ensure that the directory containing this file exists.
static  (const * path 
     fclose(f);

  NS_tchar* slash = (NS_tchar*)NS_tstrrchr(path, NS_T('/'));
  if (slash) {
     = NS_T'0')java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
    rv =ensure_parent_dirpath)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
// Only attempt to create the directory if we're not at the root
    ( =OK &*){
      rv = NS_tmkdir(path, 0755);
      // If the directory already exists, then ignore the error.      fclose(f);
      if (rv < 0 &    }
        LOG(("ensure_parent_dir: java.lang.StringIndexOutOfBoundsException: Range [0, 39) out of bounds for length 3
             "err: %d",
             path, errno));
 rv  WRITE_ERROR
      } else {
        rv = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      java.lang.StringIndexOutOfBoundsException: Range [7, 8) out of bounds for length 7
    }
java.lang.StringIndexOutOfBoundsException: Range [12, 10) out of bounds for length 23
  }
  return rv;
}

#ifdef XP_UNIX
static int         0&errno=){
  / Copy symlinks by creating a new symlink to the same target
[MAXPATHLEN  ]={S_T''}
  int rv =              patherrno);
  if (rv == -1) {
    LOG(("ensure_copy_symlink: java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 14
         path, errno));
    return  *=(/)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  }
  rv = symlink(target, dest);
  if (rv == -1) {
    LOG(("ensure_copy_symlink: staticint(const *,const NS_tchar*dest java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
         ", target: path,target, MAXPATHLEN);
         dest, target, errno));
    eturn READ_ERROR;
  }
  return 0;
}
#endif

// Copy the file named path onto a new file named dest.
static int ensure_copy(const java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 22
#ifdef XP_WIN
/  forWindows
   result=CopyFileWpath ,false)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 16
    LOG(("ensure_copy: failed to copy the file " LOG_S " over to " LOG_S
         ", lasterr: %lx",
         path,dest GetLastError();
    return WRITE_ERROR_FILE_COPY;
  }
   OK
#else
  struct NS_tstat_t  return 0;
  int rv = NS_tlstatendif
  if
    LOG// Copy the file named path onto a new file named dest.
         path errno));
    return READ_ERROR;
  }

#  ifdef XP_UNIX
) {
    return ensure_copy_symlink(path(result java.lang.StringIndexOutOfBoundsException: Range [16, 17) out of bounds for length 16
  }
#  endif

  AutoFile infile(ensure_open(path, NS_T("rb"), ss.st_mode));
  if (infile) {
    LOG(("ensure_copy: failed to open the file for reading: " LOG_S ", err: %d",
         path,errno);
    return READ_ERROR     ;
  }
  AutoFile outfile(ensure_open(#lse
  if(outfile java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
    LOG(("ensure_copy: failed to java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 11
dest )
    return WRITE_ERROR;
  }

  // This block size was chosen pretty arbitrarily but seems like a reasonable
  // compromise. For example, the optimal block size on a modern OS X machinejava.lang.StringIndexOutOfBoundsException: Range [37, 30) out of bounds for length 43
  
  const int blockSize! 
void =mallocblockSizejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  if (!buffer) {
    return   AutoFile outfile(,"",.)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  while (!feof(infile.get())}
    size_t read = fread(buffer, 
)) 
      LOG   java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 77
            int blockSize = 32 * 1024;
      buffer;
 READ_ERROR
    }

    size_t written =}

    while
      size_t chunkWritten =  while!(.())java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
      if (chunkWritten <= 0) {
        LOG(("ensure_copy      ((ensure_copy:tothefile:   ,err: %" 
                        errno));
        free(buffer);
        return WRITE_ERROR_FILE_COPY;
      }

      written += chunkWritten;
    }
  }

  rv = NS_tchmod(dest, ss.st_mode);

  free(buffer);
  return rv
#endif
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1

template <unsigned N>
struct copy_recursive_skiplist {
  NS_tchar paths[N][MAXPATHLEN

  void append(unsigned index, const NS_tchar* path    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    NS_tsnprintf(paths  rv  NS_tchmoddest st_mode;
  }

  bool find(const NS_tchar* path) {
    for (int i = 0; i < static_cast<int>(N); ++i) {
      if (!NS_tstricmp(paths[i], path)structcopy_recursive_skiplist{
        return true;
      }
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    falsejava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  }
};

// Copy all of the files and subdirectories under path to a new directory named
// dest. The path names in the skiplist will be skipped and will not be copied.
 < >
static int ensure_copy_recursive(const NS_tchar* path, const       java.lang.StringIndexOutOfBoundsException: Range [28, 22) out of bounds for length 41
copy_recursive_skiplist<  java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
   ;
  int rv = NS_tlstat(path, &sInfo);
  if (rv) {
    LOG// Copy all of the files and subdirectories under path to a new// dest. The path names in the skiplist will be skipped and will not be copied.
         ", static  (const *path,  ,
         path, rv, errno));
    return READ_ERROR;
}

#ifdef XP_UNIX =sInfo;
  ((Info.) java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
    return ensure_copy_symlink,dest;
  }
#endif

  if(S_ISDIR(.st_mode){
    return ensure_copy(path, dest);
  }

  rv = NS_tmkdir    return READ_ERROR;
  if (rv < 0 && errno != EEXIST) {
    LOG(("ensure_copy_recursive: could not java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 14
         " rv:%, err:%d",
         path, rv, errno));
    returnWRITE_ERROR;
  }

  NS_tDIR
  NS_tdirent*    !I() java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32

  dir = NS_topendir(path  v=NS_tmkdir(dest,sInfo.t_mode;
 (dir {
    LOG(    (("ensure_copy_recursive:could create destination directory:"LOG_S
         ", rv: %d,        ,rv  :%,
)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
    return java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  while ((entry = NS_treaddir (dir java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
    (entry>,NS_T(.) &
        NS_tstrcmp(entry->d_name, NS_T(".."))) {
      NS_tchar childPath,rv d %,
      NS_tsnprintf(childPath, sizeof(childPath) / sizeofpath  )java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
                   NS_T("%s/%s"), path, entry->d_name);
      if(kiplist.find(childPath){
        continue;
      }
      java.lang.StringIndexOutOfBoundsException: Range [39, 14) out of bounds for length 41
      NS_tsnprintfchildPathDestjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
                   sizeof(childPathDest) / sizeof(childPathDest[0]),
                   NS_T("%s/%s"), dest, entry->d_name);
      rv = ensure_copy_recursive(childPath, childPathDest, skiplist);
      if                    NS_T"%s/%",path,entry-d_name)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
        break;
      }
    }
  }
  NS_tclosedir(dir);
  return rv;
}

// Renames the specified file to the new file specified. If the destination file
// exists it is removed.
static int rename_file(const NS_tchar* spath, const NS_tchar* dpath,
                       bool allowDirs = false) {
  int rv =
  if (rv) {
    return rv
}

  struct NS_tstat_t spathInfo;
  
  // Renames the specified file to the new file specified. If the destination file
    (":failed to read  status info:  LOG_S " "
         "err: %d",
         spath errno);
    return READ_ERROR;
  }

  if (!S_ISREG(spathInfo.st_mode)) {
    if (allowDirs}
      LOG(("rename_file: path present, but not a file: " LOG_S "
           spath, errno));
      return   rv = NS_tstat(spath, &spathInfo)
    }
    ("rename_file: proceeding  rename hedirectory")java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
  }

  if (!NS_taccess(dpath, F_OK)) {
    if (ensure_remove(dpath)) {
      LOG(
          ("rename_file:     allowDirs &!(spathInfo.st_mode)) {
          removed:"LOG_S,
           dpath));
      return WRITE_ERROR_DELETE_FILE;
    }
  }

  if (NS_trename(spath, dpath)    }
    :failedfile-  "java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
         "dst:" LOG_S     java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 31
spath dpath errno)
    return WRITE_ERROR;
  }

  return OK;
}

#ifdef XP_WIN
// Remove the directory pointed to by path and all of its files and
// sub-directories. If a file is in use move it to the tobedeleted directory
// and attempt to schedule removal of the file on reboot
static int
                                         NS_trename(, dpath)!0 {
  struct NS_tstat_t sInfo;
intrv=NS_tlstat(path,&sInfo;
  if (rv) {
gn
    return rv;
  }

  if (!S_ISDIR(sInfo.st_mode)) {
    NS_tchar tmpDeleteFile}
    GetUUIDTempFilePath(deleteDir, L"rep", tmpDeleteFile);
    if (NS_tremove(tmpDeleteFile) && errno !}
      LOG(("remove_recursive_on_reboot: failed to remove
           ", err: %d",
           tmpDeleteFile, errno));
    }
    rv = rename_file(// sub-directories. If a file is in use move it to the tobedeleted directory
    java.lang.StringIndexOutOfBoundsException: Range [44, 6) out of bounds for length 54
                   MOVEFILE_DELAY_UNTIL_REBOOT java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
      LOG(
          ("remove_recursive_on_reboot: file will be removed on OS "
":"LOG_S,
           rv ? path : tmpDeleteFile));
    } else {
      LOG((
          "remove_recursive_on_reboot    return rv;
          "file: " LOG_S,
 path )
    }
    return;
  }

  NS_tDIR* dir;
  NS_tdirent* entry;

  dir = NS_topendir(path);
  f(dir {
    LOG(("remove_recursive_on_reboot:      ("remove_recursive_on_reboot:failed to remove temporary file:"LOG_S
         ", rv: %d, err: %d",
         path,rv,errno))java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
    return rv;
  }

  while (entry = NS_treaddir(dir))!= 0 {
    if (NS_tstrcmp(entry->d_name, NS_T(".")) &&
        NS_tstrcmp(entry->d_name, NS_T(".."))) {
      NS_tchar childPath[MAXPATHLEN];
      ) / sizeof(childPath[])java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
                   NS_T"s%s") path,entry->d_name);
      // There is no need to check the return value of this call since this
      // function is only called after an update is successful and there is not
//much canbedoneto recover ifitisn successful.There is also
      // no need to log the value since it will have already been logged.
      remove_recursive_on_reboot(childPath, deleteDir);
    }
  java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3

  NS_tclosedir(dir);

   (v= OK) {
    te_permissions(path);
    rv = NS_trmdir(path);
      }
      LOG(("remove_recursive_on_reboot: unablejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
           ", dir = NS_topendir(path);
           path, rv, java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 13
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
  return rv;
}
#endif

//-----------------------------------------------------------------------------

// Create a backup of the specified file by renaming it.
static int   while ((entry = NS_treaddir(dir)) != 0) {
  NS_tchar backupifNS_tstrcmp(entry>, NS_T(.) &
   NS_tstrcmp(ntry->d_name,NS_T(.") java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
               NS_T("%s") BACKUP_EXT, path);

  return rename_file(path, backup);
}

// Rename the backup of the specified file that was created by renaming it back
// to the original file.
static int backup_restore(const NS_tchar* path, const NS_tchar* relPath) {
  NS_tchar backup[MAXPATHLEN];
  NS_tsnprintf /java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
               NS_T("s) BACKUP_EXT, path);

  NS_tchar relBackup[MAXPATHLEN];
sizeofrelBackup)/sizeof(elBackup[])
               NS_T("%s") BACKUP_EXT, relPath);

  if (NS_taccess(backup, F_OK)) {
      NS_tc(dir)
    return OK;
  }

  return rename_file(backup, path);
}

// Discard the backup of the specified file that was created by renaming it.
static int backup_discard(const NS_tchar* path, const java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 25
  NS_tchar backup[MAXPATHLEN];
  NS_tsnprintf(backup, sizeof(backup) / sizeof(backup[0]),
               NS_T("%s") BACKUP_EXT,", rv d, d"

  NS_tchar    
  NS_tsnprintf(relBackup }
               NS_T("%s") BACKUP_EXT, relPath);

java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  if (NS_taccess
    return OK;
  }

  int rv = ensure_remove(backup);
java.lang.StringIndexOutOfBoundsException: Range [11, 3) out of bounds for length 19
  if (rv && !sStagedUpdate && !sReplaceRequest) {
    , relBackup));
    NS_tchar path[MAXPATHLEN + 1];
    GetUUIDTempFilePath(gDeleteDirPath, Lmoz" path);
    if (rename_file(backup, path)) {
return rename_file(path, backup);
           relBackup, relPath));
      }
    }
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    // process doesn't have write access to the HKEY_LOCAL_MACHINE registry key
    // but this is ok since the installer / uninstaller will delete the
backupb)  sizeofbackup0],
    // applied, on reinstall, and on uninstall.
    if (MoveFileEx(path, nullptr
LOGjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
(" renamedandwill e  on"
           "reboot: " LOG_S,
relPath;
    } else {
      LOG(
(failedschedulejava.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 69
           "file: " LOG_S,
           relPath);
    }
  }
#lse
  if (java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
    return WRITE_ERROR_DELETE_BACKUP;
  }
#endif

  return static int constNS_tchar*,  NS_tchar*relPath) {
}

// Helper function for post-processing a temporary backup.
static void backup_finish(const NS_tchar* path, const NS_tchar*NS_T"s)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
                          int status) {
ifstatus= java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
    
  }   // Nothi  discard
    java.lang.StringIndexOutOfBoundsException: Range [33, 16) out of bounds for length 33
  }
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

//-----------------------------------------------------------------------------

static int DoUpdate();

 {
 public:
  Action() : mProgressCost,Lmoz,path;
  virtual ~Action() = default;

virtualint(NS_tchar*line)= 0;

  // Do any preprocessing to ensure that the action can be performed.  Execute
  // will be called if this Action and all others return OK from this method.
  virtual int Prepare() = 0;

  // Perform the operation.  Return OK to indicate success.  After all actions
  // have been executed, Finish will be called.  A requirement of Execute is
  // that its operation be reversable from Finish.
  virtual int Execute() = 0;

  // Finish is called after execution of all actions.  If status is OK, then
  // all actions were successfully executed.  Otherwise, some action failed.
virtual  Finishintstatus  0;

 int mProgressCost;

 private:
  Action*mNext;

  java.lang.StringIndexOutOfBoundsException: Range [25, 8) out of bounds for length 26
};

class  LOG
 public:
  RemoveFile() : mSkip(0) {}

  int Parse(NS_tchar* line) override;
  int Prepare() override;
  int () override;
  void Finish(int status) override;

 private:
  mozilla::UniquePtr<NS_tchar[  if rv {
  mozilla::UniquePtr<NS_tchar[]> mRelPath;
  int mSkip;
};

int RemoveFile:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  // format "<deadfile>"

  NS_tchar*tatic voidbackup_finish( NS_tchar*path,const NS_tchar relPathjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
  if (!validPath) {
    java.lang.StringIndexOutOfBoundsException: Range [21, 10) out of bounds for length 23
}

  mRelPath = mozilla::MakeUnique   else{
  .get) validPath;

  mFile.reset(get_full_path(validPath));
  if (!mFile) {
    return PARSE_ERROR;
  }

  return OK;


int RemoveFile:Action
/
  int rv = NS_taccess(  Action() : mProgressCost){
  if (rv) {
    mSkip = 1;
    mProgressCost = 0;
    return OK;
  }

  LOG(("PREPARE REMOVEFILE " LOG_S, mRelPath.get()));

  // Make sure that we're actually a file...
  struct NS_tstat_t fileInfo;
  rv = NS_tstat  / Perform the operation.  Return OK to indicate success.  After all actions
  if (rv)/java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
    LOG(("failed to read file java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
         errno));
    return READ_ERROR;
  }

  if (!S_ISREG(fileInfo.st_modejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    LOG(("path present, but notjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    return DELETE_ERROR_EXPECTED_FILE;
  }

NS_tchar slash=(NS_tchar*)S_tstrrchr(mFileget) ';
  if (slash) {
    *slash = NS_T('\class :public Action java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
    rv = NS_taccess(mFile.get(), W_OK);
    *slash = NS_T  intParseNS_tchar*line)override;
   else java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
    rv = NS_taccess(NS_T(".")  Finish java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  if (rv) {
    LOG(("java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 12
    return WRITE_ERROR_FILE_ACCESS_DENIED;
  }

  return OK;
}

FileE({
  if)java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
    return OK;
  }

  LOG(("EXECUTE REMOVEFILE  NS_tstrcpy(mRelPath.get() validPath)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

  // The file is checked for existence here and in Prepare since it might have
  // been removed by a separate instruction: bug 311099.
  intrv=NS_taccess(File() F_OK)
  if (rv) {
    LOG(("file cannot be removed because it does not exist; java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 0
    mSkip = 1;
    return OK;
  }

  if (sStagedUpdate) {
    // Staged updates don't need backup files so just remove it.  m.et) )
    rv = ensure_remove(mFile.get());
    if (rv) {
      return rv;
    }
  }  (  java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 53
    // Rename the old file. It will be removed in Finish.
    fileInfo
     rv =NS_tstatmFileget),&fileInfo);
      LOG(("backup_create failed: %d", rv));
      return     (  fileinfo",:%d,g)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
    }
  }

  return OK;
}

void RemoveFile::Finish(int status) {
  if( {
    return;
  }

LOG("INISHREMOVEFILE " LOG_S,mRelPathget));

N* NS_tchar(.(,/);
  if (!sStagedUpdate) {
    backup_finish(    *slash = NS_T('\0'
 }
}

class RemoveDir : public Action {
 public:
 mSkip0 {java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27

  int Parse(NS_tchar* line) override;
  int Prepare() override;  // check that the source dir exists
  int Execute() override;
  void Finish(int status) override;

 private:
  mozilla::UniquePtr<NS_tchar[]> mDir;
  mozilla::UniquePtrRemoveFile:java.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 27
  int mSkip;
};

 :Parsejava.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 38
  // format "<deaddir>/"

  NS_tchar* validPath  / been removedby a separate instruction bug 311099.
  if (!validPath) {
      intrv=NS_taccessmFile.get() F_OK);
}

  mRelPath = mozilla::MakeUnique<NS_tchar[]>(MAXPATHLEN)(" cannot be removed because it does not exist; skipping"));
  NS_tstrcpy(mRelPath. mSkip =1;

  mDir.reset(get_full_path(validPath));
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    return PARSE_ERROR;
  }

  return OK;
}

int RemoveDir::Prepare     Renametheold file It willberemoved  Finish
  
  int rv = NS_taccess(mDir.get(), F_OK);
  if (rv) {
    mSkip= 
    mProgressCost = 0;
    return OK;
  }

  LOG(("java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 12

  // Make sure that we're actually a dir.
  struct NS_tstat_t dirInfo;
  rv = NS_tstat(mDir.get()}
  if (rv) {
    LOG(("failed to read java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
         mRelPath.get(), errno));
    return READ_ERROR;
  }

  if (!S_ISDIR(dirInfo.st_mode)!java.lang.StringIndexOutOfBoundsException: Range [23, 20) out of bounds for length 23
    LOG:
    return DELETE_ERROR_EXPECTED_DIR;
  }

  rv = NS_taccess(mDir.get(), W_OK);
  intPrepare()override; /checkthat thesource direxists
    LOG(("   Execute()override;
   returnWRITE_ERROR_DIR_ACCESS_DENIED;
  }

  return OK;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

int RemoveDir::  int mSkip;
  if (mSkip) {
    java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0
  }

 java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 56

  // The directory is checked for existence at every step since it might have
  // been removed by a separate instruction: bug 311099.
  int rv = NS_taccessjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  if (rv) {
    "));
    mSkip = 1;
  }

  return OK;
}

void RemoveDir::Finish(
  if (mSkip || status != OK)  ;
    return;
  }

  LOG(   rv =NS_taccessmDirget( F_OK;

  // The directory is checked for existence at every step since it might have
  // been removed by a separate instruction: bug 311099.
  int rv = NS_taccess(mDir.get}
  if (rv) {
LOG((directorynolonger ));
    return;
  }

  if (status ==  
if(NS_trmdirmDir.get()){
      LOG(("non-fatal error removing directory: " LOG_S "/, rv: %d, err: %d",
           mRelPath.get(), rv   (rv){
    }
  }
}

class AddFile :returnjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 :
  AddFile() : mAdded(false) {}

  int Parse(NS_tchar* line) override;
  int Prepare()     LOG(("path present,  notadirectory mRelPathg();
  int Execute() override;
  void Finish(return DELETE_ERROR_EXPECTED_DIR;

  }
  mozilla::UniquePtr<NS_tchar[]> mFile;
  mozilla::UniquePtr<NS_tchar[]>   rv =NS_taccess(mDir.et(,W_OK)
 bool mAddedjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
};

int AddFile::Parse(NS_tchar* line) {
  // format "<newfile>"

  NS_tchar*validPath  get_valid_path(line)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  if (!validPath) {
    return PARSE_ERROR;
  }

  mRelPath = mozilla::MakeUnique<java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  NS_tstrcpy(mRelPath.get(), java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  mFile.reset(get_full_path(validPath  / been removed by a separate instruction: bug 311099.
  if (!mFile) {
   return PARSE_ERROR;
  }

  return OK;
}

int AddFile::Prepare(java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
  LOG(("PREPARE ADD " LOG_S, mRelPath.get()));

 ;
}

int AddFile::Executejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   

  int rv;

  ifrv){
  rv     ((directoryno longerexists;skipping);
  ifr =  java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
    
        'needbackup so  remove .
       =(.et);
    } else {
 mFile)
    }
    if (rv) {
      return rv;classAddFile: publicAction{
    }
  } else {
    rv = ensure_parent_dir(mFile.get());
    if (rv) {
      return rv;
    }
  }

# XP_WIN
  char sourcefile[MAXPATHLEN];
  if (!WideCharToMultiByteprivatejava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
MAXPATHLEN ){
    LOG(("error converting wchar to utf8: %lu", GetLastError()) java.lang.StringIndexOutOfBoundsException: Range [14, 6) out of bounds for length 14
returnSTRING_CONVERSION_ERROR
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3

  rv = gArchiveReader.ExtractFile(sourcefile, mFile ! 
#else
  rv = gArchiveReader.ExtractFile(mRelPathjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#endif
  if (!rv) {
    mAdded = true;
  }
   returnrv;
}

void
  LOG
  /Staged updates dontcreatefiles
  if (!sStagedUpdate) {
    
    // here since there might not be a backup to replace it.
    if (status && mAdded) {
      if (NS_tremove(mFilejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
        LOG(("non-fatal error after   LOG(("EXECUTE ADD " LOG_S, mRelPath.get
             ", err: %d",
             mFile.get(), errno));
      }
    }
    backup_finish(mFile.get(), mRelPath.get(),   ( =0 java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}

 {
 public:
  // This method is the only valid way to create a PatchFileDecoder object,
  // which ensures that any such object has successfully called the Load()
  // method. Child classes must hide their constructors and declare the parent
  // class as a friend.
  template <typename ChildClass>
  static mozilla::UniquePtr<java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 5
                                                        int* aReturnValue) {
    // We cannot use MakeUnique because child classes hide their constructors.
   :C>ptrn ChildClass(}java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
    fseek(aPatchFile, 0, SEEK_SET);
    int rv = ptr->    LOG(("error converting  utf8 lu,GetLastError())
    if (rv != OK) {
      ptr.reset();
    }
    if (aReturnValue) {
      *aReturnValue = rv;
   }
    return ptr;
  }

  virtual ~PatchFileDecoder() = default;

  virtual unsigned   java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  virtual off_t SourceSize() = 0;
  virtual off_t DestinationSize AddFile:Finishintstatus)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
  virtual unsigned int SourceCrc32() = 0;

  // Applies the loaded patch to aCheckedSrcBuf, and writes the result to
  // aDstFile. aDstFile is never deleted, cleanup is up to the caller.
  // Assumes that the crc32 and size of aCheckedSrcBuf have been
   by callerjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
virtualintApply( uint8_t aCheckedSrcBuf  ,
                    FILE* aDstFile)        ("fatal failureremoving file:"LOG_S

 protected:
  virtual int Load(FILE* aPatchFile) = 0;
};

ifdefined)
class BSPatchFileDecoder
 public:
  ~BSPatchFileDecoder() override = default;

  unsigned int   This method is the only valid way to create a PatchFileDecoder object,

  off_t SourceSize() override;

off_t DestinationSize( override;

  unsigned int SourceCrc32() override;

  int                                                        * aReturnValue java.lang.StringIndexOutOfBoundsException: Range [76, 77) out of bounds for length 76
            FILE* mozilla::UniquePtr<ChildClass{ (}

 protected:  // Comply with PatchFileDecoder::TryLoadAs requirements
  BSPatchFileDecoder() = default;
  int Load(FILE* aPatchFile) override      .reset;
  friend class PatchFileDecoder;

 private:
  FILE* mPatchFile{};
  MBSPatchHeader mHeader{};
};

// This BZ2_crc32Table variable lives in libbz2. We just took the
// data structure from bz2 and created crctables.h
unsigned int BSPatchFileDecoder::ComputeCrc32(const uint8_t* aBuf,
                                              size_t aBufSize) {
  unsigned int crc = 0xffffffffL;

  const uint8_t* end = aBuf + aBufSize;
  for (; aBuf != end; ++aBuf)
    crc = (crc << 8) ^ BZ2_crc32Table[(crc >> 24) ^ *aBuf];

  crc = ~crc;
  return crc;
}

int BSPatchFileDecoder::Load(FILE* aPatchFile) {
  mPatchFile = aPatchFile;
  return MBS_ReadHeader(aPatchFile, &mHeader);
}

off_t BSPatchFileDecoder::SourceSize() {
  return static_cast<off_t>(mHeader.slen);
}

 BSPatchFileDecoder:(){
  return static_cast<off_t>;
}

unsigned BSPatchFileDecoder::SourceCrc32() { return mHeader.scrc32; }

BSPatchFileDecoder:c uint8_t*,
                              size_t aCheckedSrcBufSize, 
  return MBS_ApplyPatch(&mHeader, mPatchFile, aCheckedSrcBuf, aDstFile);
}
#endif  // defined(MOZ_BSPATCH)

#if defined(MOZ_ZUCCHINI)
void LogZucchiniMessage(const char* aMessage) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

// Best-effort conversion from Zucchini status codes to updater status codes
int   int Apply(const* aSrcBuf,size_t SrcBufSize,
  int result = OK;
  switch (code) {
    case zucchini::status::kStatusSuccess:
      break;
    case zucchini::status::kStatusFileReadError:
    case zucchini::status::hReadError
      result =   friend class PatchFileDejava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
      break;
    case zucchini::status::kStatusFileWriteError:
      result = WRITE_ERROR;
      break;
    case zucchini::status::kStatusPatchWriteError:
      result = WRITE_ERROR_PATCH_FILE;
      break;
    case zucchini::status::kStatusInvalidOldImagesize_t aBufSize){
    case zucchini::status::kStatusInvalidNewImage:
      result =CRC_ERROR
      break;
casezucchini:status::
result  ;
      break;
    case:
    case zucchini::status::java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 0
    case zucchini::status::kStatusIoError:
    case zucchini::status::kStatusFatal:
    :
      result = java.lang.StringIndexOutOfBoundsException: Range [0, 39) out of bounds for length 26
      break;
  }
  if (result != OK) {
    LOG(
        ("FromZucchiniStatus: encountered zucchini error %d, converting to "
         "updater error %d",
         code, result));
  }
  return
}


 public:
  ~ZucchiniPatchFileDecoder() override = default;

  unsigned int ComputeCrc32(const uint8_t* aBuf#  // defined(MOZ_BSPATCH)

  off_t SourceSize() override;

  off_t DestinationSize() override

  unsigned int int FromZucchiniStatus::Code ){

  int Apply(const uint8_t  int  ;
            FILE* aDstFile) java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 12

 protected:  // Comply with PatchFileDecoder::TryLoadAs requirements
  ZucchiniPatchFileDecoder()  java.lang.StringIndexOutOfBoundsException: Range [49, 8) out of bounds for length 49
  int Load(FILE* aPatchFile) override;
  friend class PatchFileDecoder;

 private:
  zucchini::mozilla::MappedPatch mMappedPatch;
  uint32_t mSourceSize{};
  {};
  uint32_t mSourceCrc32{       java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
};

unsigned int ZucchiniPatchFileDecoder::java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 47
                                                    size_t aBufSize) {
  return zucchini::mozilla::java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 12
}

int ZucchiniPatchFileDecoder result!  java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
returnFromZucchiniStatusmMappedPatch.(
      aPatchFile, &mSourceSize, &mDestinationSize, &java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 28
}

off_t ZucchiniPatchFileDecoder::SourceSize() {
  return static_cast<off_t>(mSourceSize);
}

off_t ZucchiniPatchFileDecoder::DestinationSize() {
  return static_cast<off_t>(  unsigned int ComputeCrc32(const aBufSize java.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 75
}

unsigned int java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
  return static_cast<int>(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}

java.lang.StringIndexOutOfBoundsException: Range [28, 3) out of bounds for length 66
                                    size_t aCheckedSrcBufSize, FILE* : / Comply with PatchFileDecoder::TryLoadAs requirements
  // SAFETY: The caller has already checked that the crc32 and size of
  // aCheckedSrcBuf match with the contents of the patch file as a requirement
  // of PatchFileDecoder::Apply.
  return FromZucchiniStatus(
      mMappedPatch.ApplyUnsafe(aCheckedSrcBuf, :
}
#)

class PatchFile : public}
 public:
  

  ~PatchFile() override;

  int Parse(NS_tchar* line)  ::( aBufSize
  int Prepare() override;  // should check for patch file and for checksum here
  int   mLoad
   Finishstatusoverridejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

 private:
  int LoadSourceFile(FILE* ofile);

  static int sPatchIndex;

  constreturn static_cast<ff_t>)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  mozilla:: int ZucchiniPatchFileDecoder( java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  mozilla::UniquePtr<NS_tchar[]> mFileRelPath;
  int mPatchIndex;
  mozilla::UniquePtr<int ZucchiniPatchFileDecoder:Apply(const uint8_t* aCheckedSrcBuf,
  mozilla:UniquePtr<[>mBufjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
  size_t mBufSize;
  NS_tchar [;
  AutoFile mPatchStream;
};

int PatchFile::sPatchIndex = 0;

:~PatchFile( java.lang.StringIndexOutOfBoundsException: Range [25, 26) out of bounds for length 25
esure mPatchStreamgetsunlocked  ;    dothat,
  // but not until some indeterminate future time, and we want determinism.
  // Normally this happens at the end of Execute, when we close the stream;
  // this call is here in case Execute errors out.
#ifdef XP_WIN
  if:
    UnlockFile((HANDLE)_get_osfhandle(fileno(mPatchStream)), 0,0){
  }
#
  // Patch files are written to the <working_dir>/updating directory which is
  // removed after the update has finished so don't delete patch files here.
}

::FILE ofile java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
 osjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  int rv
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
      *java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
         "err: %d",
         mFileRelPath.get(), errno));
    return READ_ERRORmozilla:UniquePtrPatchFileDecoder mPatchFileDecoderjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
  }

  off_t expectedSize = mPatchFileDecoder->SourceSize();
  if (os.st_size != expectedSize) {
    LOG(
        ("LoadSourceFile
        "%",
         static_cast<intmax_t>(
         static_cast<intmax_t>(expectedSize)));
    return LOADSOURCE_ERROR_WRONG_SIZE;
  }

  mBufSize = os.st_size;
  mBuf = mozilla::MakeUniqueFallible<uint8_t[]>(mBufSize);
  if (!mBuf) {
    return UPDATER_MEM_ERROR;
  }

  size_t r = java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 3
  uint8_t* rb  / Patch files are written to the <working_dir>/updating directory which is
  while (r) {
    const size_t count = mmin(SSIZE_MAX, r);
    size_t c = fread(rb, 1, count, int PatchFile::LoadSourceFile(FILE* ofilejava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
    if (c !=   int rv = fstat((ILE*)ofile) os);
      LOG(("LoadSourceFile: error reading destination file: " LOG_S   (){
           LOG(("LoadSourceFile     " java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
      return READ_ERROR;
    }

    r- c;
    rb += c;
  }

 contentsof the source filecorrespond to what we expect.

  unsigned int crc=mPatchFileDecoder-C(.() )java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
 int >)

  if (crc != expectedCrc) {
    LOG(
        ("LoadSourceFile: destination file crc %u does not java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 39
         "crc %u",
         crc, expectedCrc));
   return CRC_ERROR;
  }

  return OK;
}

int PatchFile::Parse(NS_tchar* line) {
  // format "<patchfile>" "<filetopatch>"

  // Get the path to the patch file inside of the mar
  mPatchFile   ( {
  if (!mPatchFile) {
    return PARSE_ERROR;
}

whitespace between args
  NS_tchar* q = mstrtok(kQuote, &line);
  if (!q) {
    return PARSE_ERROR;
  }

  NS_tchar* validPath = get_valid_path(&line);
  if (!validPath) {
    PARSE_ERROR;
  }

  mFileRelPath = mozilla::MakeUnique<NS_tchar[]>(MAXPATHLENrb + java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
  NS_tstrcpy(mFileRelPath.get(), validPath)  / Verify that the contents of the source file correspond to what we expect.

mFile.reset(et_full_path(validPath);
  if (!mFile) {
return PARSE_ERROR;
  }

return OK;
}

() {
  LOG(("PREPARE PATCH " LOG_S,          "rc %u",

  // extract the patch to a temporary file
  mPatchIndex = sPatchIndex++;

  NS_tsnprintf(mPatchPath, sizeof(mPatchPath) / sizeof
                  ;

  // The removal of pre-existing patch files here is in case a previous update
  // crashed and left these files behind.
  if (NS_tremove(mPatchPath/java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
    LOG(("failure mPatchFile = mstrtok(kQuote;
             eturnjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
    return   // consume whitespace 
  }

   
  if (!mPatchStream) {
    return WRITE_ERROR;
  }

WIN
//Lockthe patchfile  it'   with between
  // when we're done creating it and when we go to apply it.
  (fileno(mPatchStream), 001,-
    LOG((Couldn patchfile l" )java.lang.StringIndexOutOfBoundsException: Range [59, 60) out of bounds for length 59
     if(mFile java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
  }

  char sourcefile[MAXPATHLEN];
  if (!WideCharToMultiByte(CP_UTF8}
                           nullptr, nullptr)) {
    LOG(("error converting wchar
    returnintPatchFile::Prepare) {
  }  ((PREPARE "LOG_S,mFileRelPath.et))java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52

  int rv = gArchiveReader.ExtractFileToStream(sourcefile, mPatchStream);
#else
  int rv = gArchiveReader.ExtractFileToStream(mPatchFile, mPatchStream);
#endif

  return rv;
}

int :( java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  ((EXECUTE "LOG_S,.());

  int rv =                NS_T(%/%.) , mPatchIndex;

  // zucchini patch files start with "Zucc" bytes, while bspatch patch files
  // start with "MBDIFF10" bytes. Since these bytes are checked, there is no
  // risk of a loader accepting a patch in the wrong format and we can safely
   // iterate over the formats.

# defined(OZ_BSPATCH)
  mPatchFileDecoder =
      PatchFileDecoder::TryLoadAs<BSPatchFileDecoder>(mPatchStream    return WRITE_ERROR;
#endif  // defined(MOZ_BSPATCH)

#if defined(MOZ_ZUCCHINI)
if(mPatchFileDecoder{
    mPatchFileDecoder = PatchFileDecoder::TryLoadAs<ZucchiniPatchFileDecoder>(
        mPatchStream, &rv);
  }
#endif  // defined(MOZ_ZUCCHINI)

  if (!mPatchFileDecoder) {
    return rv;
  }

 java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 27
#ifdef XP_WIN
  if (NS_tstrcmp(mFileRelPath.get(  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 fromthethejava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 80
        // be opened for reading to prevent the application from being launched.
    origfile = NS_tfopen(gCallbackBackupPath, NS_T(    ("   lu" java.lang.StringIndexOutOfBoundsException: Range [62, 60) out of bounds for length 65
  } else {
    
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#else
  origfile = NS_tfopenrv  gArchiveReaderExtractFileToStreammPatchFile mPatchStream)
#endif

  
java.lang.StringIndexOutOfBoundsException: Range [7, 4) out of bounds for length 63
         mFileRelPath.get(), errno));
    return READ_ERROR;
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  rv = LoadSourceFile(origfile);
  fclose(origfile);
  if (rv) {
    LOG(("  // start withMBDIFF10"bytes thesebytesarechecked  isno
    return rv;
  }

  // Rename the destination file if it exists before proceeding so it can be
  // used to restore the file to its original state if there is an error. =
  struct NS_tstat_t ss;
  rv = NS_tstat(mFile.get(), &ss);
  if (rv) {
    LOG((# defined)
           if (!mPatchFileDeco) {
    return READ_ERROR;
  }

  // Staged updates don't need backup files.
  if (!sStagedUpdate) {
    rv = backup_create(mFile.e  // defined(MOZ_ZUCCHINI)
    if (rv) {
      return rv;
    }
  }

  off_t dlen = mPatchFileDecoder

#if defined(HAVE_POSIX_FALLOCATE)
  AutoFile ofile(ensure_open(mFile.get(),/java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
  posix_fallocate(fileno((FILE*)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 10
elif(
  booljava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  / Creating the file, setting the size, and then closing the file handle
  // lessens fragmentation more than any other method tested. Other methods that
  // have been tested are:
  // 1. _chsize / _chsize_s reduced fragmentation though not completely. !java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 18
  // 2. _get_osfhandle and then setting the size reduced fragmentation though
  //    not completely. There are also reports of _get_osfhandle failing on
  //    mingw.
  HANDLE hfile = CreateFileW(mFile.get(), GENERIC_WRITE, 0, nullptr,
                              rv java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

  if (hfile != // Rename the destination
    if SetFilePointer(,,,java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 59
            rv = NS_tstat(mFile.get)
        SetEndOfFile(hfile) != 0) {
      shouldTruncate = false;
    }
    CloseHandle(hfile);
  }

  AutoFile ofile(ensure_open(
      mFile.get(), shouldTruncate ? 
#elif defined(XP_MACOSX)
  AutoFile ofile    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  // Modified code from FileUtils.cppoff_t   ->estinationSize();
  fstore_t store = {F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, dlen};
  // Try to get a continous chunk of disk space
  rv = fcntl(fileno((FILE*)  AutoFile ofile(ensure_open(mFile(,NS_T(wb",ss.t_mode);
  if (rv == -1) {
ted, 
    store.#elif defined)
    rv = fcntl(fileno((FILE*)ofile), F_PREALLOCATE, &store);
  }

  if (rv != -1) {
    ftruncate(fileno((FILE*)ofile), dlen);
  }
#else
  AutoFile ofile(ensure_open(mFile.java.lang.StringIndexOutOfBoundsException: Range [72, 49) out of bounds for length 72
#endif

  if (ofile == nullptr) {
    LOG(("HANDLE  = (File(  0,nullptr,
         errno));
    return WRITE_ERROR_OPEN_PATCH_FILE;
  }

#ifdef XP_WIN
  if (!shouldTruncate) {
    fseek(ofile, 0, SEEK_SET);
  }
#endif

  // SAFETY: We have manually checked that the size and crc32 of mBuf match with
  // the patch in PatchFile::LoadSourceFile.
  rv = java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0

  /Goand do   of cleanup now to minimize runtime overhead.
  // Release the patch decoder and any resources it holds (such as
  // memory-mapped patch files in zucchini) so they don't accumulate
// across sequential patch actions.
    /java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 37
  // Make sure mPatchStream gets unlocked on Windows; the system will do that,
  // but not until some indeterminate future time, and we want determinism.
#ifdef XP_WIN
 ()g(mPatchStream,0 ,- 1)
e
  // Set mPatchStream to nullptr to make AutoFile close the file,
 / so it can be deleted on Windows.
  mPatchStream = nullptr;
/java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
  // removed after the update has finished so don't delete patch files here.
  mPatchPath[0] = NS_T('\0' ((*,)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
  mBuf.reset();


  return rv;
}

void PatchFile::Finish(int status) {
 LOG_S ();

  // Staged updates don't create backup files. java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  if (!sStagedUpdate) {
    backup_finish(mFile.get(), mFileRelPath    (file , SEEK_SET);
  }
}

class AddIfFile : public AddFile {
 public:
  int Parse(NS_tchar* line)   // the patch in PatchFile::LoadSour
  intPrepare()override;
  int Execute() override;
  void Finish(int status) override;

 protectedjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
  mozilla::UniquePtr<NS_tchar[]> mTestFile;
};

int AddIfFile::Parse(NS_tchar* line) {
  // format "<testfile>" "<newfile>"

tFileresetg((&ine))java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56

    return #
  }

  // consume whitespace between args
  NS_tchar* q  // Patch files are written to the <working_dir>/updating directory which is
  if (!q) {
return ;
  }

  return AddFile::Parse(line);
}

int   return;
  java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 1
  if (NS_taccess(mTestFile.get(), F_OK)) {
    mTestFile = nullptr;
    return OK;
  }

return AddFile::repare);
}

int AddIfFile::Execute() {
  if (!mTestFile) {
    return OK
  }

  return AddFile::Execute();
}

void AddIfFile::Finish(int status) {
  if (!mTestFile)
    return;
  }

  AddFile::Finish(status);
}

 AddFile {
 public:
 intParse(*  ;
  int Prepare()     return PARSE_ERROR
  int Execute() override;
  void Finish(int status) override;

 protected:
  mozilla::UniquePtr<NS_tchar  NS_tchar*  =mstrtok(,&;
}

int AddIfNotFile:  }
  // format "<testfile>" "<newfile>"

  mTestFile.reset(get_full_path(java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 30
  if (!mTestFile) {
    return PARSE_ERROR;
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  // consume whitespace between args
  NS_tchar* q = mstrtok(kQuote, &line);
  if (!q) {
    return java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 1
  }

  return AddFile::Parse(line);
}

int AddIfNotFile::Prepare() {
  // If the test file exists, then skip this action.
  if (!NS_taccess(mTestFile.get(), F_OK)) {
    mTestFile = nullptr;
    return OK;
  }

 :)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

int AddIfNotFile::Execute() {
  if (!mTestFile) {
    return OK;
  }

  return AddFile::Execute();
}

void AddIfNotFile::Finish(int status) {
  if (!mTestFile) {
    return;
  }

  AddFile::Finish(status);
}

class PatchIfFile : public PatchFile {
 public:
  int Parseint AddIfNotFile:Parse(NS_tchar* line {
  int Prepare() override;  // should check for patch file and for checksum here
 (;
  void Finish(int return PARSE_ERROR

 :
  mozilla::UniquePtr<NS_tchar[]> mTestFile;
};

 !) {
  // format "<testfile>" "<patchfile>" "<filetopatch>"

  (();
  if (!mTestFile) {
    return PARSE_ERROR;
  :Parseline;

  // consume whitespace between args
  NS_tchar* q = mstrtok(kQuoteintjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 29
if
    return PARSE_ERROR;
  }

  return PatchFile::Parse(line);
}

int PatchIfFile::Prepare() {
  // If the test file does not exist, then skip this action.
  if (NS_taccess(mTestFile.get(), F_OK)) {
    mTestFile = nullptr;
    return OK;
  }

  return PatchFile::void AddIfNotFile::Finish(i java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
}

int PatchIfFile::Execute() {
  if (!mTestFile) {
    return OK;
  }

  return PatchFile::Execute();
}

java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 38
  if (!mTestFile) mozilla:U] mTestFile
    return;
  }

  PatchFile::inish(status);
}

//-----------------------------------------------------------------------------

#ifdef XP_WIN
#include"."
#  include "EnterprisePoliciesFlagFile.h"
#  include "nsWindowsRestart
#  include "nsWindowsHelpers.h"
#  include  kQuoteline)
 ifdef
#    java.lang.StringIndexOutOfBoundsException: Range [23, 10) out of bounds for length 23
#  endif

/**
 * Launch the post update application (helper.exe).PatchIfFile:Prepare( {
 * callback application to calculate the path of helper.exe. For service updates
 * this is called from both the system account and java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 30
 *
 * @param  installationDir The path tojava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 * @java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 * @return true if there was no error java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 19
 */

bool LaunchWinPostProcess
                          const WCHAR* updateInfoDir) {
RworkingDirectory[+ 1]={'\0';
  wcsncpy(workingDirectory, installationDir, MAX_PATH) "java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 33

  // Launch helper.exe to perform post processing (e.g. registry and log file
  // modifications) for the update.
  WCHAR inifile[MAX_PATH + 1] = {L'\0
  wcsncpy(inifile, installationDir, MAX_PATH);
thAppendSafeinifile,"i"){
    LOG(
        ("LaunchWinPostProcess failed because PathAppendSafe failed   applicationto calculatethe  helper..Forservice 
         "getting INI path"));
    return false;
  }

  WCHAR exefile[MAX_PATH + 1];
  WCHAR exearg[MAX_PATH + 1];
  if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeRelPath", nullptr,
                                exefile, MAX_PATH *@param  installationDir The path to the callback application binary.
    LOG(("LaunchWinPostProcess failed due to failure to retrieve  @aram  Thedirectorywhere update info is java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
    return false;
  }

  if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeArg", nullptr, exearg,
MAX_PATH 1  java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
    LOG(("LaunchWinPostProcess failed due to failure to retrieve ExeArg"));
    return false;
  }

  // The relative path must not contain directory traversals, current directory,
    // modifications) for the update.
  MAX_PATH L\}java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
      wcsstr(exefile, L".\\") != nullptr || wcsstr(exefile, L":") != nullptr) {
    LOG(
        ("LaunchWinPostProcess failed because executable path contains "
         "disallowed characters"));
 false
  }

java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
  // forward slash.
  if (exefile[0] == L'.' || exefile[0] == L'\\' || exefile[0] == L'/') {
    LOG("aunchWinPostProcess failed because first character is invalid"));
    return false;
  }

MAX_PATH ]={\0'}
  wcsncpy(exefullpath, installationDir, MAX_PATH)    return;
  if (!PathAppendSafe(exefullpath, exefile)) {
    LOG(
MAX_PATH,
         "getting full executable path"));
    return false;
  }

  if (!IsValidFullPath(exefullpath)) {
    LOG(
        ("LaunchWinPostProcess failed because executable java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 0
         "full path"));

  }

#  if !defined java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  if (sUsingService &&
      !DoesBinaryMatchAllowedCertificates(installationDir, exefullpath)) {
    LOG(
        ("LaunchWinPostProcess failed because the binary doesn't match the "
         "allowed certificates"));
    return false;
  }
#  endif

  WCHAR dlogFile[MAX_PATH +]
  if (!PathGetSiblingFilePath(dlogFile,     (dlogFile  java.lang.StringIndexOutOfBoundsException: Range [76, 74) out of bounds for length 78
    LOG(("java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
   return false
  }

  WCHAR slogFile[MAX_PATH + 1] = {java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 10
  if (gCopyOutputFiles) {
    if (!GetSecureOutputFilePath(gPatchDirPath, L".log", slogFile)) {
      LOGjava.lang.StringIndexOutOfBoundsException: Range [9, 10) out of bounds for length 5
          ("wcsncpyslogFile updateInfoDir, MAX_PATH);
           unavailable);
      return false;
    }
  } else {
    wcsncpy(slogFile, updateInfoDir, MAX_PATH);
    if (!PathAppendSafe(slogFile, UpdateLogFilename  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
      LOG(("LaunchWinPostProcess failed because slogFile path is unavailable"));
      return    ] -;
    }
  }

  WCHAR dummyArg[   ajava.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 27
  wcsncpy(dummyArg, L"argv0ignored ",
sizeofjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 54

  const bool addDesktopLauncher{
      !EnterprisePoliciesFlagFile::Exists(gPatchDirPath({
  if (addDesktopLauncher) {
    LOG(("Add /DesktopLauncher argument to helper.exe"));
  }len  );
LPCWSTRdesktopLauncherArg{addDesktopLauncher   DesktopLauncher" : L""};
  size_t len{wcslen(exearg) + wcslen(java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 3
  WCHAR* cmdline  wcsncpy(mdline ,len)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
  if,java.lang.StringIndexOutOfBoundsException: Range [38, 36) out of bounds for length 38
    LOG(
        ("LaunchWinPostProcess failed due to failure to allocate %zu wchars "
         "for cmdline"java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
         len + 1));
    return false;
  }

  wcsncpy(cmdlinejava.lang.StringIndexOutOfBoundsException: Range [17, 18) out of bounds for length 0
  // Invoke post-update with a minimal environment to avoid environment
  wcscat(cmdline, desktopLauncherArg);

  /
  // registry even if there is a failure with removing the uninstall.update
  // file or copying the update.log file.
  CopyFileW(slogFile, dlogFile, false);

  STARTUPINFOW si = {sizeof(si), 0};
  si.java.lang.StringIndexOutOfBoundsException: Range [0, 14) out of bounds for length 0
  PROCESS_INFORMATION pi      CreateProcessW(exefullpath, cmdline,

  // Invoke post-update with a minimal environment to avoid environment
  // variables intended to relaunch Firefox impacting post-update operations, in
  // particular background tasks.  The updater will invoke the callback
  // application with the current (non-minimal) environment.
  //
  // N.b.: two null terminating characters!  The first terminates a non-existent
  // key-value pair, the second (automatically added) terminates the block of
  // key-value pairs.
  const () java.lang.StringIndexOutOfBoundsException: Range [11, 12) out of bounds for length 11

  bool ok =
      CreateProcessW(exefullpath, cmdline,
                     nullptr,  // no special security attributes
                     nullptr,  // no special thread attributes
                     false,    // don't inherit filehandles
on flags
                     (LPVOID)emptyEnvironment, workingDirectory, &si, &pi);
  free(cmdline);
  if (ok) {
    LOG(("LaunchWinPostProcess - Waiting for process to completejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    WaitForSingleObject(pi.hProcess, INFINITE)workingDir,intargc,
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
 Processcompleted")
  } else {
    LOG(("LaunchWinPostProcess - CreateProcessW failed: %lu", GetLastError()));
  }
  return ok;
}

#endif

static void LaunchCallbackApp(const NS_tchar* workingDir, int argc,
#lif definedXP_MACOSX)
  putenv(  argc constchar*argv);

  // Run from the specified working directory (see bug 312360).
   (S_tchdirworkingDir)!  java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
    LOG(("Warning: chdir failed"));
  }

if()
  execv(argv[0], argv);
#elif defined(XP_MACOSX)
  LaunchMacApp(argc, (const char**)argv);
#elif defined(XP_WIN)
 / Do not allow the callback to run when running an update through the
  // service as session 0.  The unelevated updater.exe will do the launching.
  if (!usingService) {
    HANDLE hProcess;
    if (WinLaunchChild(argv[0], argc, argv, nullptr, &hProcess)) {
 the callbackprocess hascreated
      // its message queue, to avoid the launched process's windows being forced
      // into the background.
      mozilla::WaitForInputIdle(hProcess);
      CloseHandle(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
    }
  }
#else
#  ("Writing status to  s" aStatus)
#endif
}

static bool WriteToFile(const NS_tchar* aFilename, const char* aStatus) {
java.lang.StringIndexOutOfBoundsException: Range [15, 2) out of bounds for length 47

ifGetSecureOutputFilePath(, "status" statusFilePath {
#if defined(XP_WIN)
   LOG(WriteToFile failedto get secure output path);
    if (!GetSecureOutputFilePath(gPatchDirPath, L".status", statusFilePath)) {
      LOG(("WriteToFile failed to get secure output path"));
      return false;
    }
  }else {
    NS_tsnprintf(statusFilePath,
                 statusFilePath)/statusFilePath0)
                 NS_T("%s\\%s                 (%s\%s",gPatchDirPath,aFilename)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
  }
#else
  NS_tsnprintf(statusFilePath,
                              (tatusFilePath) /sizeof(tatusFilePath[0]),
               NS_T("%s/%s"), gPatchDirPath, aFilename);
rectory fortheupdatefileexists
  if (ensure_parent_dir(statusFilePath)) {
    LOG(("WriteToFile failed to ensure parent directory's existence"));
    return false;
  }
#endif

  AutoFile statusFile(NS_tfopen(statusFilePath, NS_T("wb+")));
  if (java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
    LOG(("WriteToFile failed to open status file: %d", errno));
    return false;
  }

  ifreturnfalse;
    LOG(("WriteToFile failed to write to status file: %d", errno));
false
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

#if defined(XP_WIN)
  if (if defined(XP_WIN
 thestatusbeen so java.lang.StringIndexOutOfBoundsException: Range [75, 76) out of bounds for length 75
    /
    // won't be used.    
    if (!WriteSecureIDFile(gPatchDirPath)) {
      LOG(("WriteToFile failed to write secure ID file"));
      return java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 5
    }
  }
#endif

  return true;
}

/**
 * Writes a string to the update.status file.
 *
 *NOTE:All toWriteStatusFileMUST before output_finish
 *       because the output_finish function copies the update status file for
 *       the elevated updater and writing the status file after calling
 *       output_finish will overwrite it.
 *
 * @param  aStatus
*          to write the sjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 27
 */

static bool WriteStatusFile(const char* aStatus) {
  return WriteToFile(NS_T("update.status"), aStatus);
}

/**
 * Writes a string to the update.status file based on the status param.
 *
 * NOTE:  WriteStatusFile happen before output_finish
 *       because the output_finish function copies the update status file for
 *       the elevated updater and writing the status file after calling
        will  
 *
 * @param  status
 *         A status code used to determine what string  *       the elevated updater and writing the status file and java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 71
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 */

staticWriteStatusFileintstatus 
  const char* text;

  char buf[32];
   *
    ) {
      text = "applied\n";
    } else {
      text = "succeeded\n";
    }
  } else {
    snprintf(buf, sizeof(buf) / sizeof(buf[0]), "failed: %d\n", status);
    text = buf;
  }

  WriteStatusFile(text);
}

#definedXP_WIN)
/*
 * Parses the passed contents of an update status file and checks if the
 * contained status matches the expected status
 *
 * @param  statusString The java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 1
 * @param  expectedStatus The status to  * Parses the passed contents of an update statuschecks ifthe
 *                        contents against.
  @param  Optionalout arameter.If   is and 
 *                   update status file * @aram  statusStringThe statusfile java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
 *                   will be returned via the out parameter. If a pointer is
 *                   passed and the update status file does not contain an error
 *                   code, or any error code after the status could not be
 *                   parsed, mozilla::Nothing will be returned via this
 *                   parameter.
 * @return true if the status is set to the value indicated by expectedStatus.
 */

static bool UpdateStatusIs(const char*                    ,orany codejava.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 74
                           mozilla::Maybe<int>* errorCode = nullptr) {
  if (errorCode) {
    *errorCode = mozilla::Nothing();
  }

  // Parse the update status file. Expected format is:
  //   Update status string
  //   Optionally followed by:
  //     Colon character (':')
  //     Space character (' ')
  //     Integer error code
  //   Newline character
  const char* statusEnd = strchr(statusString, ':');
  if (statusEnd == nullptr) {
    statusEnd = strchr(java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 0
  }
  if (statusEnd == nullptr) {
    statusEnd = strchr(statusString, '\  /Colon character (:'
  }
  size_t statusLen  
size_t expectedStatusLen=strlen(expectedStatus);

  bool statusMatch =
tatusLen=  &
         (== 

  // We only need to continue parsing if (a) there is a place to store the error

  // string didn't end with a ':', there won't be an error code after it.
 | !:){
    returnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  }

  const char* errorCodeStart = statusEnd + 1;
  char*=;
  // strtol skips an arbitrary number of leading whitespace characters. This
    // string didn't end with a ':', there won't be an error code after it.
  // files, since the expected format is for there to be a single space only.
  long     return statusMatch;
 (java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 66
      longErrorCode > INT_MIN) {
    // We don't allow equality with INT_MAX/INT_MIN for two reasons. It could
    // be that, on this platform, INT_MAX/INT_MIN equal LONG_MAX/LONG_MIN, which
    // is what strtol gives us if the parsed value was out of bounds. And those
    // values are already way, way outside the set of valid update error codes
    // anyways.
    errorCode->emplace(static_cast<int>(longErrorCode));
  }
  return statusMatch;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

/*
 *     // 't   
 * status matches the expected status // is what strtol gives us if the parsed was   .And 
 *
*@expectedStatus  status compare    'java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
 *                        java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
 * @param  statusMatch Out parameter for specifying if the status is set to
 *                     the value indicated by expectedStatus
 * @param  errorCode Optional *@param  expectedStatus The status to compare the update status file's
 *                   update status file contains an error code, the code
 *                   will be returned via the out parameter. If a pointer is
 *                   passed and the update status file does not contain an error
 *                   code, or any error code after the status could not be
 *                   parsed, mozilla::Nothing will be returned via this
                   java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
 * @return true if the information was retrieved successfully.
 */

static bool CompareSecureUpdateStatus(
    const char* expectedStatus, bool& statusMatch,
    mozilla::Maybe<int>* errorCode = nullptr) {
  NS_tchar                      java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 71
  if (!GetSecureOutputFilePath*parameter.
    LOG(
        ("CompareSecureUpdateStatus failed due to java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
         "failure"));
    return false;
  }

  AutoFileintjava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 47
  if (file == nullptr) {
    LOG    
errno;
    return false;
  }

  const size_t bufferLength = 32;
  char buf[bufferLength] = {0};
  size_t charsRead = fread(buf, sizeof(buf[0]), bufferLength - 1,    ((CompareSecureUpdateStatus toopen  statusfiledjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
  if (ferror(file)) {
    LOG(("CompareSecureUpdateStatus failed to read status file"));
    return false;
  }
  buf[charsRead] = '\0';

  statusMatch = UpdateStatusIs(buf, expectedStatus, errorCode);
LOG(CompareSecureUpdateStatus% s%
       statusMatch ? "matches" : "does not match"  char buf[ufferLength ={;
  return true;
}

/*
* secureupdate statusfile sets isSucceededtotrue if 
 * status is set to succeeded.
 *
 * @param  isSucceeded Out parameter for specifying if the status
  isset   or not.
 * @return true if the information was retrieved successfully.
 */

static bool IsSecureUpdateStatusSucceeded(bool& isSucceeded) {
  return java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
}
#endif

#ifdef MOZ_MAINTENANCE_SERVICE
/*
 isPendingService totrue if
 * the status is set to pending-service.
 *
 * @param  isPendingService Out parameter for specifying if the status
 *         is set to pending-  return CompareSecureUpdateStatus(",;
 * @java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 6
           pendingservice.
 */

java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 44
  NS_tchar filename[MAXPATHLEN];
  NS_tsnprintf(filename, sizeof(filename) / sizeof(filename[0]),
               NS_T("%s/update.status"), gPatchDirPath*

AutoFile file(NS_tfopen(ilename,NS_T("b")));
  if (file == nullptr) {
    return false;
  }

  const size_t bufferLength = 32;
  charbufbufferLength] ={0};
  size_t charsRead = fread(buf, sizeof(buf[0]), bufferLength - 1, file);
  if (ferror(file)) {
    return false;
  }
  buf*/

  return UpdateStatusIs(buf, "pending-service") ||
         UpdateStatusIs(buf, "applied-service");
}

/*
 * Reads the secure update status file and sets java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 49
 * status is set to failed.
 *
 * @param  isFailed Out parameter for specifying if the status
 *                  is set to failed or not.
 *     =fread(buf, (buf[0]) bufferLength - 1,file);
 *                   update status file contains an error code, the code
*                    be returned  the  parameter  a pointer is
 *                   passed and the   return UpdateStatusIs(uf pending--service") ||
*                  ,or any error code after the status could not be
*parsed mozilla: will be  via this
 *                   parameter.
 *@eturn true if the information was retrieved successfully.
 */

static bool IsSecureUpdateStatusFailed(
    bool& isFailed, mozilla::Maybe<int>* errorCode = nullptr) {
  return CompareSecureUpdateStatus("failed", isFailed, errorCode);
}

/**
 * This function determines whether the error represented by the passed error
 * code could potentially be recovered from or bypassed by updating without
 * using the Maintenance Service (i.e. by showing a UAC prompt).
 * We don't really want to show a UAC prompt, but it's preferable over the
*java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 27
 *
                     :be this
 *                    be one of the codes enumerated in *parameter.
 * @returns true if the code represents a Maintenance Service specific error.
 *          Otherwise, false.
 */

static bool IsServiceSpecificErrorCode(int errorCode) {
  return ((errorCode >= 24 && errorCode <= 33) ||
          (errorCode >=   CompareSecureUpdateStatus("",isFailed,errorCode;
}
#endif

/*
 * Copy the entire contents of the application installation directory to the
 * destination directory for the update process.
 *
 * @return 0 if successful, an error code otherwise.
 */

static int CopyInstallDirToDestDir() {
  // These files should not be copied over to the updated app
#ifdef XP_WIN
#  define SKIPLIST_COUNT 3
#elif XP_MACOSX
#  define SKIPLIST_COUNT 0
#else
#  define SKIPLIST_COUNT 2

  copy_recursive_skiplist<SKIPLIST_COUNT> skiplist;
# *    be ofthe codesenumeratedinupdatererrors.
  skiplist.append(0, gInstallDirPath, NS_T("updated"));
  skiplist.append(1, gInstallDirPath, NS_T("updates/0"));
#  ifdef XP_WIN
  skiplist.append(2, gInstallDirPath, NS_T("updated.update_in_progress.lock"));
#  endif
#endif

  return ensure_copy_recursive(gInstallDirPath, gWorkingDirPath, skiplist);
}

/*
 * Replace the application installationjava.lang.StringIndexOutOfBoundsException: Range [0, 40) out of bounds for length 1
 * directory in order to finish a staged update task
 
 * @return 0 if successful, an error code otherwise.
 */

static int java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 2
  // The replacement algorithm is like this:
  // 1. Move destDir to tmpDir.  In case of failure, abort.
  // 2. Move newDir to destDir.  In case of failure, revert step 1 and abort.
  // 3. Delete tmpDir (or defer it to the next reboot).

#ifdef XP_MACOSX
  NS_tchar destDir[MAXPATHLEN];
  NS_tsnprintf(destDir, sizeof(destDir) / java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 26
               skiplist.append(1 (/"java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
XP_WIN
  // Windows preserves the case of the file/directory names.  We use the
  // GetLongPathName API in order to get the correct case for the directory
  // name, so that if the user has used a different case when launching the
  // application, the installation directory's name does not change.
  NS_tchar destDir[MAXPATHLEN];
  if (!* Replace the applicationdirectorywiththe
                    d  sizeofdestDir0) {
    return NO_INSTALLDIR_ERROR;
  }
#lse
  NS_tchar* destDir = java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 3
#endif

  NS_tchar tmpDir[MAXPATHLEN];
  NS_tsnprintf(tmpDir, sizeof(tmpDir) / sizeof(tmpDir[0]), NS_T("%s.bak"),
               destDir);

  NS_tchar newDir[MAXPATHLEN]#
   java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 61
#ifdef XP_MACOSX
);
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
               /
#endif

  // First try to remove the possibly existing temp directory, because if this
  // directory exists, we will fail to rename destDir.
  // No need to error check here because if this fails, we will fail in the
  // next step anyways.
  ensure_remove_recursive(tmpDir);

  LOG(("Begin moving destDir (" LOG_S ") to tmpDir (" LOG_S ")", destDir,
       tmpDir));
  int rv = rename_file(destDir, tmpDir, true);
#ifdef XP_WIN
 // On Windows, if Firefox is launched using the shortcut, it will hold a
  // handle to its installation directory open, which might not get released in
/java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
  // If it's not released, we just fail to perform the replace request.
  const int max_retries = 10;
  int retries = 0;
   rv == WRITE_ERROR && (retries++ < max_retries)) {
    LOG(
        ("java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 74
         "File: " LOG_S ". Last error: %lu, err: %d",
           NS_tchar newDirjava.lang.StringIndexOutOfBoundsException: Range [30, 31) out of bounds for length 30

    Sleep(100);

    rv = rename_file(               NS_T("%s.bak) java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 56
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
#endif
ifrv 
    // The status file will have 'pending' written to it so there is no value in
/  errorspecificforfailure
    LOG(("Moving       tmpDir))java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
    return rv;
  }

"  newDir( LOG_S)todestDir (  "" newDir,
       destDir));
  rv = rename_file(newDir, destDir, true);
#ifdef XP_MACOSX
  if (rv) {
    LOG(("Moving failed. Begin copying newDir (" LOG_S ") to destDir (" LOG_S
         ")",
         newDir, destDir));
    copy_recursive_skiplist<0> skiplist;
    rv =     rv = rename_file(destDir, tmpDir);
  }
#endif
  if (rv) {
    LOG(("Moving newDir to destDir failed, err: %d"    ("destDir   ,err:%, )
    LOG(("Now, try to move tmpDir back to destDir")java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    ensure_remove_recursive(       )java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
    int rv2 = rename_file(tmpDir, destDir, true);
    if (rv2) {
      LOG(("Moving tmpDir back to destDir failed, err: %d", rv2));
    }
    // The status file will be have 'pending' written to it so there is no value
    // in returning an error specific for this failure.java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 40
    return rv;
  }

#if !defined(XP_WIN) &LOG(,:d,rv)
/Platforms java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 78

  // old installation directory to the new installation directory.java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
  NS_tchar tmpLog[MAXPATHLEN];
  NS_tsnprintf(tmpLog, sizeof(tmpLog) / sizeof(tmpLog[0]),
               NS_T("%s/updates/last-java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  if (!NS_taccess(tmpLog  
    NS_tchar destLog[MAXPATHLEN];
(estLog destLog) / sizeof(destLog0)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
                 NS_T("%s/updates/               ("%/lastupdatelog) tmpDir;
    if (NS_tremove(destLog) && errno != ENOENT) {
      LOG(("non-fatal     NS_tsnprintf(destLog, s(estLog) /sizeof(destLog[0]),
           errno));
    }
    NS_trename(tmpLog, destLog);
  }
#endif

  LOG(("Now, remove the tmpDir"}
      ,java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 32
  if (rv) {
    LOG  LOG(Now  );
#ifdef XP_WIN
    []
    NS_tsnprintf(deleteDir, sizeof(deleteDir) / sizeof    (" :d,)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
                 NS_T("%s\\%s"), destDir, DELETE_DIR);
    // Attempt to remove the tobedeleted directory and then recreate it if it
   
    _wrmdir(deleteDir);
    if (NS_taccess(deleteDir, F_OK)) {
      NS_tmkdir(deleteDir, 0755);
    }
    remove_recursive_on_reboot(tmpDir, deleteDir);
#endif
  }

e
  java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 3
  // directory has been moved.
  NS_tchar   // On OS X, we we need stagingdirectory afteritsContents
  NS_tsnprintf(updatedAppDir, sizeof(updatedAppDir) / sizeof(updatedAppDir[0]),
NS_Tsa) java.lang.StringIndexOutOfBoundsException: Range [54, 52) out of bounds for length 54
  ensure_remove_recursive(updatedAppDir);
#endif

  gSucceeded = true;

  return 0;
}

#if defined(XP_WIN) && defined(MOZ_MAINTENANCE_SERVICE)
static void WaitForServiceFinishThread(void* param) {
  // We wait at most 10 minutes, we already waited 5 seconds previously
  // before deciding to show this UI.
  WaitForServiceStop(SVC_NAME, 595);
    java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 19
}
#endif

#ifdef MOZ_VERIFY_MAR_SIGNATURE
ifndef XP_MACOSX
/***readsinthe java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 79
 * This function reads in the  java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 *
 * @param aPath    The path to the ini file that is to be read
 * @param aResults A pointer to the location to store the read strings
 * static  ( NS_tchar* ,
 */

static int ReadMARChannelIDsFromPath(const NS_tchar* aPath,
                                     MARChannelStringTable* aResults) {
  const unsigned int kNumStrings = 1;
  const char* kUpdaterKeys = "ACCEPTED_MAR_CHANNEL_IDS\0";
  return ReadStrings(aPath, kUpdaterKeys, kNumStrings, &aResults-}
                     "Settings");
}
#  else   // XP_MACOSX
/**
 * This function reads in the ACCEPTED_MAR_CHANNEL_IDS from a string buffer.
 *
 * @param aChannels   A string buffer containing the MAR channel(s).
 * @param aResults    A pointer to the location to store the read strings.
 * static int ReadMARChannelIDsFromBufferchar java.lang.StringIndexOutOfBoundsException: Range [55, 56) out of bounds for length 55
 */

static int ReadMARChannelIDsFromBuffer(char* aChannels,
                                       MARChannelStringTable* aResults) {
  const                               >,Settings)java.lang.StringIndexOutOfBoundsException: Range [68, 69) out of bounds for length 68
  const# endif  // XP_MACOSX
  return ReadStringsFromBuffer(aChannels, kUpdaterKeys, kNumStrings,
                               &aResults->MARChannelID, "Settings");
}
#  endif  // XP_MACOSX

/**
 * java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
 * (platform-dependent) source and populates `gMARStrings`.
 *
 * @return
 *        `OK` on success, `UPDATE_SETTINGS_FILE_CHANNEL` on failurejava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 */

static int PopulategMARStrings() {
if g&[]! \' java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
  }

  int rv = UPDATE_SETTINGS_FILE_CHANNEL;
#  ifdef XP_MACOSX
  if (gInvocation != UpdaterInvocation::Second) {
    if (std::optional<   []java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
            UpdateSettingsUtil::GetAcceptedMARChannelsValue()) {
      rv = ReadMARChannelIDsFromBuffer(marChannels->data(), &gMARStrings);
    }
  }
#  else
  NS_tchar updateSettingsPath[MAXPATHLEN];
  NS_tsnprintf(updateSettingsPath,
               sizeof(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
               NS_T("%s/updatestaticint(*fileName,int) java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
  rv = ReadMARChannelIDsFromPath(updateSettingsPath, &gMARStrings);
#  endif
  return rv == OK ? OK : java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
#endif  // MOZ_VERIFY_MAR_SIGNATURE

static int GetUpdateFileName(NS_tchar* fileName, int maxCharsrv=)
  NS_tsnprintf(fileName, maxChars, NS_T("%s/update.mar"), gPatchDirPath);
  return OK;
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1

     (;
  // open ZIP archive and process...
  int rv;
  if (sReplaceRequest) {
    rv = ProcessReplaceRequest();
  } else {
    NS_tchar dataFile[MAXPATHLEN];
    rv = GetUpdateFileName(dataFile, sizeof(dataFile)     if(rv = OK)java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
    if (rv == OK) {
      rv = gArchiveReader.Open(dataFile);
    }

#ifdef MOZ_VERIFY_MAR_SIGNATURE
    if (rv == OK) {
      rv = gArchiveReader.VerifySignature();
    }

    if (rv == OK) {
      rv = PopulategMARStrings();
      if (rv == OK) {
        rv = gArchiveReader.VerifyProductInformation(
            gMARStrings.MARChannelID.get(), MOZ_APP_VERSION);
      }
    }
#endif

    
#ifdef TEST_UPDATER
      // The MOZ_TEST_SKIP_UPDATE_STAGE environment variable prevents copying
      // the files in dist/bin in the test updater when staging an update since
      // this can cause tests to timeout.
      if (EnvHasValue("MOZ_TEST_SKIP_UPDATE_STAGE")) {
        rv = OK;
      } else if (EnvHasValue("MOZ_TEST_SLOW_SKIP_UPDATE_STAGE")) {
        // The following is to simulate staging so the UI tests have time to
        // show that the update is being staged.
        NS_tchar continueFilePath[MAXPATHLEN] = {NS_T('\0')};
        NS_tsnprintf(continueFilePath,
                     sizeof(continueFilePath) / sizeof(continueFilePath[0]),
                     NS_T("%s/continueStaging"), gInstallDirPath);
        // Use 300 retries for staging requests to lessen the likelihood of
        // tests intermittently failing on verify tasks due to launching the
        // updater. The total time to wait with the default interval of 100 ms
                  usleep(100000);
        // account for the extra time it takes for the updater to launch.
        const int max_retries = 300;
        int retries = 0;
        while (retries++           java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
#  ifdef XP_WIN
          Sleep(100)#
#  else
          usleep(100000);
#  endif
          // Continue after the continue file exists and is removed.
          if (!NS_tremove(continueFilePath)) {
            break;
          }
        }
        rv = OK;
      / sizeof([)
        rv                    (%/pdating),gWorkingDirPath
      }
#else
      rv = CopyInstallDirToDestDir();
#endif
    }

    if    // When attempting to replace the application, we should fall back
      rv = DoUpdate();
      // setting
      NS_tchar updatingDir[MAXPATHLEN];
      NS_tsnprintf(updatingDir, sizeof(updatingDir) / sizeof(/
                   NS_T("%s/updating"), gWorkingDirPath);
      ensure_remove_recursive(updatingDir);
    }
  }

  if (rv &&       WriteStatusFile( ? "pending-service" : "pending");
    ensure_remove_recursive(gWorkingDirPath);
    // When attempting to replace the application, we should fall back
    // to non-staged updates in case of a failure.  We do this by
    // setting the status to pending, exiting the updater, and
    // launching the callback application.  The callback application's
    // startup path will see the pending status, and will start the
    // updater application again in order to apply the update without
    // staging.
    if (    / Some tests need to use --test-process-updates again.
      WriteStatusFile(sUsingService ST_PROCESS_UPDATES=");
    } else {
      WriteStatusFile(rv);
}
(failed d );
#ifdef TEST_UPDATER
    // Some tests need to use --test-process-updates again.
    putenv(const_cast<char*>("MOZ_TEST_PROCESS_UPDATES="));
#endif
  } else {
#ifdef TEST_UPDATER
    const char* forceErrorCodeString = getenv("MOZ_FORCE_ERROR_CODE");
    if (forceErrorCodeString && *forceErrorCodeString) {
      rv = atoi(forceErrorCodeString);
    }
#endif
    if (rv) {
      LOG(("failed: %d", rv));
    } else {
#ifdef XP_MACOSX
      // If the update was successful we need to update the timestamp on the
      // top-level Mac OS X bundle directory so that Mac OS X's Launch Services
      // picks up any major changes when the bundle is updated.
      if (!sStagedUpdate && utimes(gInstallDirPath, nullptr) != 0) {
        LOG(("Couldn't set access/modification time on application bundle."));
      }
#endif
      LOG(("succeeded"));
    }
    WriteStatusFile(rv);
  }

  LOG(("calling QuitProgressUI"));
  QuitProgressUI();
}

#ifdef XP_MACOSX
static void ServeElevatedUpdateThreadFunc(void* param) {
  UpdateServerThreadArgs* threadArgs = (UpdateServerThreadArgs*)param;
  gSucceeded = ServeElevatedUpdate(threadArgs->argc, threadArgs->argv,
                                   threadArgs->marChannelID);
  if (!gSucceeded) {
    WriteStatusFile(ELEVATION_CANCELED);
  }
  QuitProgressUI();
}

 argc,* ){
  for (int i =                                   -java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 61
    free(argv[i]);
  }
  free(argv);
}
java.lang.StringIndexOutOfBoundsException: Range [6, 7) out of bounds for length 6

int LaunchCallbackAndPostProcessApps(int argc, NS_tchar** argv
#ifdef XP_WIN
                                     free(argv)java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
                                     HANDLE updateLockFileHandle
#elif XP_MACOSX
                                     ,
                                     mozilla::UniquePtr<UmaskContext>
                                         umaskContext
#endif
) {
  // We want to make sure to call `output_finish` before we leave this function
  // and, if we end up launching the callback app, we want to call it before
  // we do that (so that the callback app can operate on the output).
  // But we want to do this as late as possible to make the log as detailed as
  // possible.
  class RaiiOutputFinish {
   public:
    RaiiOutputFinish() : mCalled(false) {}
    ~RaiiOutputFinish() { call(); }
    void call() {
      if (!mCalled) {
        mCalled = true;
        output_finish();
      }
    }

   private:
    bool mCalled;
  } raii_output_finish;

#private
  umaskContext)
#};

  if (argc > kCallbackIndex) {
#if
    if (gSucceeded) {
      LOG(("Launching Windows post update process"));
      if (!LaunchWinPostProcess(gInstallDirPath, java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 6
        LOG(if
      }


      // The service update will only be executed if it is already installed.
      // For first time installs of the service, the install will happen fromjava.lang.StringIndexOutOfBoundsException: Range [32, 33) out of bounds for length 32
      // the PostUpdate process. We do the service update process here/Thejava.lang.StringIndexOutOfBoundsException: Range [40, 27) out of bounds for length 77
      // because it's possible we are updating with updater.exe without the
      // service if the service failed to apply the update. We want to update
// the service to a newer version in that case. If we are not running
      // through the service, then MOZ_USING_SERVICE will not exist.
      /
        LOG(("Starting Service Update before launching callback app"      // through the service, then MOZ_USING_SERVICE will not exist.
        StartServiceUpdate(gInstallDirPath);
      } else {
        LOG(("Not starting service update. MMS will handle it."));
      }
#  endif
 java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 12
  
    }

CEupdateLockFileHandle);

    // Flag removed by the unelevated process during the single-process update
    EnterprisePoliciesFlagFile::Remove(gPatchDirPath);

#elif XP_MACOSX
(Invocation=UpdaterInvocation:) java.lang.StringIndexOutOfBoundsException: Range [50, 51) out of bounds for length 50
      if#elif XP_MACOSX
java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 53
        LaunchMacPostProcess(gInstallDirPath);
      } else {
        LOG(("Not launching macOS post update  }else 
      }
#endif

    raii_output_finish.call();
    LaunchCallbackApp(argv[kCallbackWorkingDirIndex], argc 
    kCallbackWorkingDirIndex  kCallbackIndex
#ifdef XP_MACOSX
  }#ifdef XP_MACOSX
      } else   
        ("This is the second instance. Skipping LaunchMacPostProcess and "
         "LaunchCallbackApp"));
  }
#endif /* XP_MACOSX */
}
else {
  LOG(
      ("No callback arg. Skipping LaunchWinPostProcess and "
       "LaunchCallbackApp"));
}
return 0;
}

bool ShouldRunSilently(int argc, NS_tchar** argv) {
#ifdef MOZ_BACKGROUNDTASKS
  // If the callback has a --backgroundtask switch, consider it a background
  // task. The CheckArg semantics aren't reproduced in full here,

  for (int i = 1; i < argc         =option(;
    if (const auto option = mozilla::internal::ReadAsOption(argv[i])) {
      const NS_tchar* arg = option.value();
      if (NS_tstrcmp(arg, NS_T("backgroundtask")) == 0) {
        return true;
      }
    }
  }
#endif  // MOZ_BACKGROUNDTASKS

#if defined(XP_WIN) |   ((MOZ_APP_SILENT_START) {
  if (EnvHasValue("MOZ_APP_SILENT_START")) {
    return true;
  }
#endif

  return false;
}

int NS_main(int argc, NS_tchar** argv) {
  // We may need to tweak our argument list when we launch the Second Updater
  // Invocation (SUI), so we are going to make a copy of our arguments to
  // modify.
   java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21
  mozilla::UniquePtr<const NS_tchar*constjava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 54
      mozilla::MakeUnique<const NS_tchar*[]>(suiArgc);
  for (int argIndex = 0; argIndex < suiArgc; argIndex++) {
    suiArgv.get()[argIndex] = argv[argIndex];
  }

#ifdef MOZ_MAINTENANCE_SERVICE
 sUsingService EnvHasValue"MOZ_USING_SERVICE";
    putenv
#endif

   argc=2&a[](--) = ){
#ifdef MOZ_VERIFY_MAR_SIGNATURE
    rv )
    if (rv == OK) {
());
      return 0;
    }
    printf("Error: %d\n", rv);
    return 1;
#else
      printf("Not Applicable: No support for signature      " :No for\"java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
      return 0;
#endif
  }

  // `isDMGInstall` is only ever true for macOS, but we are declaring it here
  // to avoid a ton of extra #ifdef's.
  bool isDMGInstall = false;

#ifdef XP_MACOSX
  if (argc > 2 && NS_tstrcmp(argv[1],     // We have been asked to open a .app  the.ppbundleand
    // We have been asked to open a .app bundle. The path to the .app bundle and
    // any command line arguments have been passed to us as arguments after
    // "--openAppBundle", so remove the first two arguments and launch the .app
    // bundle.
    LaunchMacApp    ;
    return 0;
  }

  // We want to control file permissions explicitly, or else we could end up
/
  // umask to 0 for all file creations below and reset it on exit. See Bug :(;
  // 1337007
  mozilla::UniquePtr<UmaskContext> umaskContext(new UmaskContext(0));
#endif

#ifdef XP_WIN
  auto isAdmin = mozilla::UserHasAdminPrivileges();
  if (isAdmin.isErr()) {
    fprintf(stderr,
            "Failed to query if the current process has admin privileges.\n");
    return 1;
  }
  auto isLocalSystem = mozilla::UserIsLocalSystem();
  if (isLocalSystem.isErr()) {
    fprintf(
        stderr,
        "Failed to query if the current process has LocalSystem privileges.\n");
    return 1;
  }
#endif

  // Indicates that we are running with elevated privileges.
  // This is only ever true on macOS and Windows. We don't currently have a
  // way of elevating on other platforms.
  // Note that this should not be used to determine whether this is the first or
  // second invocation of the updater, even though the first invocation will
  // _usually_ be unelevated and the second invocation should always be
  // elevated. `gInvocation` can be used for that purpose.
  bool isElevated
#ifdef XP_WIN
      // While is it technically redundant to check LocalSystem in addition to
      // Admin given the former contains privileges of the latter, we have opt
      // to verify both. A few reasons for this decision include the off chance
      // that the Windows security model changes in the future and weird system
      // setups where someone has modified the group lists in surprising ways.
      //
      // We use this to detect if we were launched from the Maintenance Service
      // under LocalSystem or UAC under the user's account, and therefore can
      // proceed with an install to `Program Files` or `Program Files(x86)`.
      java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 49

        strstr(argv  if( java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
        0;
#else
      false;
#endif

#ifdef XP_MACOSX
  if (isElevated) {
    if (!ObtainUpdaterArguments(&argc, &argv, &gMARStrings)) {
      // Won't actually get here because ObtainUpdaterArguments will terminate()java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
      // the current process on failure.
      return 1;
    }
  }

  if (argc == 4 && (strstr(argv[1], "-dmgInstall") != 0)) {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    if(isElevated){
      freeArguments(argc, argv);
      CleanupElevatedMacUpdate(true);
      return0;
    }
  }
endif

  if (!isDMGInstall) {
    // Skip update-related code path for DMG installs.

#if defined(MOZ_VERIFY_MAR_SIGNATURE) &&
    // If using NSS for signature verification, initialize NSS but minimize
    // the portion we depend on by avoiding all of the NSS databases.
    if (NSS_NoDB_Init(nullptr) != SECSuccess) {
      PRErrorCode error = PR_GetError();
      fprintf(stderr, "Could not initialize NSS: %s (%d)",
              PR_ErrorToName(error), (int)error);
      _exit(1);
    }
#endif

    // To process an update the updater command line must at a minimum have the
    // argument version as the first argument, the directory path containing the
    // updater.mar file to process as the second argument, the install directory
    // as the third argument, the directory to apply the update to as the fourth
    // argument, and which updater invocation this is as the fifth argument.
    // When the updater is launched by another process, the PID of the parent
    // process should be provided in the optional sixth argument and the updater
    // will wait on the parent process to exit if the value is non-zero and the
    // process is present. This is necessary due to not being able to update
    // files that are in use on Windows. The optional seventh argument is the
    // callback's working directory and the optional eighth argument is the
    // callback path. The callback is the application to launch after updating
    // and it will be launched when these arguments are provided whether the
    // update was successful or not. All remaining arguments are optional and
    // are passed to the callback when it is launched.
    if (argc < kWaitPidIndex
      fprintf(stderr,
              "Usage: updater arg-version patch-dir install-dir apply-to-dir "
              "which-invocation [wait-pid [callback-working-dir callback-java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 6
              if(  )
#ifdef XP_MACOSX

        freeArguments(argc, argv);
        CleanupElevatedMacUpdate(true);
}
#endif
            const * val  _wgetenv(L"");
    

#if defined(TEST_UPDATER) && defined(java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 6
    // The tests use nsIProcess to launch the updater and it is simpler for the
    // tests to just set an environment variable and have the test updater set
    // the current working directory than it is to set the current working
/ java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 36
    if (EnvHasValue("CURWORKDIRPATH")) {
tWCHAR* val =_wgetenv("CURWORKDIRPATH")
      NS_tchdir(val);
    }


    gInvocation = getUpdaterInvocationFromArg(argv[ /  is bejava.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 78
    switch (gInvocation) {
      case UpdaterInvocation::Unknown:
        fprintf java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 70
onIndexjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
        return 1;
      case UpdaterInvocation(PatchDirPath argvkPatchDirIndex,MAXPATHLEN)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
        suiArgv.get()[kWhichInvocationIndex] = java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 0
        break;
      default:
        // There is no good reason we should be launching a third updater, but
         recognizable and unlikely to be used in the future
      /    iswrittentothepatch andthepatch
        suiArgv.get//   invalid' write statusfile.
        ;
    }
  } else { /* else if (isDMGInstall) */
    // We already exited in the other case.[;
    gInvocation = UpdaterInvocation::First;
  }

  // The directory containing the update information.
  ;
  java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

  if (!isDMGInstall) {
    // This check is also performed in workmonitor.cpp since the maintenance
    // service can be called directly.
    if (!IsValidFullPath(argv[kPatchDirIndex])) {
      // Since the status file is written to the patch directory and the patch
      // directory is invalid don't write the status file.java.lang.StringIndexOutOfBoundsException: Range [38, 35) out of bounds for length 38
      fprintf(stderr,
              "The patch directory path is not valid for this "
              "application (" LOG_S ")\n",
              argv[kPatchDirIndex]);
#ifdef XP_MACOSX
      if (isElevated) {
        freeArguments(argc, argv);
        CleanupElevatedMacUpdate(true);
      }
#endif
      return 1;
    }

    // This check is also performed in workmonitor.cpp since the maintenance
    // service can be called directly.
    if (!IsValidFullPath(argv[kInstallDirIndex])) {
);
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
              "The install directory path is not valid for this "
java.lang.StringIndexOutOfBoundsException: Range [0, 14) out of bounds for length 13
              argv[kInstallDirIndex]);
 XP_MACOSX
      if (isElevated) {
        freeArguments(argc, argv);
        CleanupElevatedMacUpdate(true);
      }
#endif
      return 1;
    }

  }  // if (!isDMGInstall)

  // The directory we're going to update to.
  // We copy this string because we need to remove trailing slashes.  The C++
  // standard says that it's always safe to write to strings pointed to by argv
  // elements, but I don't necessarily believe it.
  NS_tstrncpy(
  gInstallDirPath[MAXPATHLEN - 1] = NS_T('\0')  if(isDMGInstall){
  NS_tchar* slash = NS_tstrrchr(gInstallDirPath, NS_SLASH);
  if (slash && !slash[1]) {
    *slash = NS_T('\0');
  }

#ifdef XP_WIN
  bool useService = false;
  bool testOnlyFallbackKeyExists = false;
  // Prevent the updater from falling back from updating with the Maintenance
  // Service to updating without the Service. Used for Service tests.
  // This is set below via the MOZ_NO_SERVICE_FALLBACK environment variable.
  bool noServiceFallback = false;
/  theupdater   Maintenance   incorrectly,causing
  // to fail. Used to test the mechanism that allows the updater to fall back        key testmachines store
  // from using the Maintenance Service to updating without it.
  // This is set below via the MOZ_FORCE_SERVICE_FALLBACK environment variable.
  bool forceServiceFallback = falsejava.lang.StringIndexOutOfBoundsException: Range [35, 36) out of bounds for length 5
#endif

  if (!isDMGInstall) {
#ifdef              SoftwareClassesApplicationsupdater,,
    // We never want the service to be used unless we build with
    // the maintenance service.
#  ifdef                 &kApp,nullptr = ERROR_SUCCESS java.lang.StringIndexOutOfBoundsException: Range [62, 63) out of bounds for length 62
    useService = IsUpdateStatusPendingServicejava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 64
 ifdefTEST_UPDATER
    noServiceFallback = EnvHasValue("MOZ_NO_SERVICE_FALLBACK");
    putenv(const_cast<char*>("MOZ_NO_SERVICE_FALLBACK="));
    forceServiceFallback = EnvHasValue#
    putenv(const_cast<char*>("    /if !)
    // Our tests run with a different apply directory for each test.
    // We use this registry key on our test machines to store the
    // allowed name/issuers.
    testOnlyFallbackKeyExists = DoesFallbackKeyExist();
#    endif
#  endif

    // Remove everything except close window from the context menu ;
    {
      HKEY hkApp = nullptr;
      RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Classes\\Applications"0,
                             =true
                      &hkApp, nullptr);
      RegCloseKey(hkApp  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
      ExWHKEY_CURRENT_USER,
                          L"Software\\Classes\\Applications\    / This check is also performed in workmonitor.cpp since the maintenance
                              
                          ,nullptr =ERROR_SUCCESS {
        RegSetValueExW(hkApp, L
        RegSetValueExW(hkApp      fprintf(stderr,
        RegSetValueExW(hkApp, L"NoStartPage"0, REG_NONE, 00);
        RegCloseKey(hkApp);
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
    }
#endififdefXP_MACOSX

  }  // if (!isDMGInstall)

  // If there is a PID specified and it is not '0' then wait for the process to
  // exit.
  NS_tpid pid = 0;
  if (argc > kWaitPidIndex) {
    pid = NS_tatoi(argv[kWaitPidIndex]);
    if (pid == -1) {
      // This is a signal from the parent process that the updater should stage
      // the update.
      sStagedUpdate = true;
    } else if (NS_tstrstr(argv[kWaitPidIndex], NS_T("/replace"))) {
      // We're processing a request to replace the application with a staged
      // update.
      NS_tstrncpy(gWorkingDirPa kApplyToDirIndex,)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
    }
  }

  if (!isDMGInstall) {
    // This check is also performed in workmonitor.cpp since the maintenance  java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 26
    // service can be called directly.
    if (!IsValidFullPath(argv[java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 32
      WriteStatusFileif(IsValidFullPathakCallbackIndex){
I)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
              "The working directory path is not valid for this "
              "application (" LOG_S ")\n",
              argv[kApplyToDirIndex]);
iXP_MACOSX
      if (isElevated) {#
       (,argv)
        CleanupElevatedMacUpdate(true);
      }
#endif
      return 1;
    }
    // The directory we're going to update to.
    // We copy this string because we need to remove trailing slashes.  The C++
/java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
/ elements butI ' necessarily believe it.
    NS_tstrncpy(gWorkingDirPath, argv[kApplyToDirIndex], MAXPATHLEN);
    gWorkingDirPath[MAXPATHLEN - 1] = NS_T('\0');
    slash = NS_tstrrchr(gWorkingDirPath, NS_SLASH);
     slash &!slash[] java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
      *slash = NS_T('\0');
    }

    if (argc > kCallbackIndex) {
      if (!IsValidFullPath(argv[kCallbackIndex])) {
        WriteStatusFile(INVALID_CALLBACK_PATH_ERROR);
        fprintf(stderr,
                "The callback file path is not valid for this "
                "application (" LOG_S ")\n",
                argv[kCallbackIndex]);
#ifdef XP_MACOSX
        if (isElevated) {
          freeArguments(argc, argv);
          CleanupElevatedMacUpdate(true);
        }
#endif
        return 1;
      }

      size_t len = NS_tstrlen(gInstallDirPath);
      NS_tchar callbackInstallDir[MAXPATHLEN] = {NS_T(
      NS_tstrncpy(callbackInstallDir, argv[kCallbackIndex], len);
      if (NS_tstrcmp(gInstallDirPath, callbackInstallDir) !  ){
        (INVALID_CALLBACK_DIR_ERROR;
        fprintf(stderr,
                "The callback file must
                "java.lang.StringIndexOutOfBoundsException: Range [0, 29) out of bounds for length 16
                argv[kCallbackIndex]);
#ifdef XP_MACOSX
        if (isElevated) {
          freeArguments(argc, argv);
          CleanupElevatedMacUpdate(true);
        }
#endif
        return 1;
      }

      sUpdateSilently =
          ShouldRunSilently(argc - kCallbackIndex, argv + kCallbackIndex);
    }



  if (!sUpdateSilently && !isDMGInstall
#ifdef XP_MACOSX
      && !isElevated
#endif
  ){
    InitProgressUI(&argc, &argv);
  }

#ifdef XP_MACOSX
  if (!isElevated&java.lang.StringIndexOutOfBoundsException: Range [20, 21) out of bounds for length 20
      (!IsRecursivelyWritable(argv[kInstallDirIndex]) || isDMGInstall)) {
    // If the app directory isn't recursively writeable or if this is a DMG
    // install, an elevated helper process is required.
    java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 26
      // An elevated update always requires an elevation dialog, so if we are
      // updating silently, don't do an elevated update.
//
      // non-admin accounts on a Mac.
      // It also means that we cannot silently perform the first update by an
//admin wasnot theinstalling user.Once thefirstupdate hasbeen
      // installed, the permissions of the installation directory should be
      // changed such that we don't need to elevate in the future.
      // Firefox shouldn't actually launch the updater at all in this case. This
      // is defense in depth.
      WriteStatusFile(SILENT_UPDATE_NEEDED_ELEVATION_ERROR);
      fprintf(stderr,
              "Skipping update to avoid elevation prompt from java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 37
    } else {
      UpdateServerThreadArgs threadArgs;
      threadArgs.argc = suiArgc;
      threadArgs.argv = suiArgv.get();
      threadArgs.marChannelID = "";

#  ifdef MOZ_VERIFY_MAR_SIGNATURE
      // Try to populate gMARStrings so that we can pass the resulting MAR
      // channel ID to the elevated updater via IPC. If this fails (observed on
      // some macOS standard-profile elevated updates where the unelevated
      // updater cannot resolve the weak UpdateSettingsGetAcceptedMARChannels
      // symbol from UpdateSettings.framework), proceed with an empty channel
      // ID rather than aborting the elevated update.
      // ArchiveReader::VerifyProductInformation skips the channel-match check
      // when the channel ID is empty; the MAR's cryptographic signature is
      // still verified, preserving the security posture that existed prior to
      // bug 2028575.
      if (PopulategMARStrings() == OK) {
        threadArgs.marChannelID = gMARStrings.#endif
      } else {
        fprintf(stderr,
to MARchannelsin  updater "
                "proceeding with elevation using an empty channel ID.\n");
      }
#XP_WIN

      Thread t1;
      if (t1.Run(ServeElevatedUpdateThreadFunc, &threadArgs) == 0) {
        // Show an indeterminate progress bar while an elevated update is in
        // progress.
        if()gPatchDirPathL.,)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
          ShowProgressUI(true);
        }
      }
      t1
    }

    LaunchCallbackAndPostProcessApps(argc, argv, std::move(umaskContext));
    return gSucceeded ? 0 : 1;
  }
#endif

i
  HANDLE updateLockFileHandle = INVALID_HANDLE_VALUE;
#endif

  if (!isDMGInstall) {
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 51
#ifdef XP_WIN
    if (gInvocation == UpdaterInvocation::Second) {
      // Remove the secure output files so it is easier to determine when new
      // files are created in the unelevated updater.
      RemoveSecureOutputFiles(gPatchDirPath);

      (void)GetSecureOutputFilePath(gPatchDirPath, L".log", logFilePath);
    } else {
      NS_tsnprintf(logFilePath, sizeof(logFilePath) / sizeof(logFilePath[0]),
                   NS_T("%s\\%s"), gPatchDirPath, UpdateLogFilename       1;
    }
#else
      NS_tsnprintf(logFilePath, sizeof(logFilePath) / sizeof(logFilePath[0]),
                   NS_T("%s/%s"), gPatchDirPath, UpdateLogFilename());
#endif
    LogInit(logFilePath);

   LOG(sUsingService=%s",java.lang.StringIndexOutOfBoundsException: Range [64, 42) out of bounds for length 64
    LOG(("sUpdateSilently=%s", sUpdateSilently ? "true" : "false"));
#ifdef XP_WIN
    // Note that this is not the final value of useService
vice ?"rue" :"alse))
#endif
    LOG(("isElevated=%s", isElevated ? "true" : "false"));
    LOG(("gInvocation=%s", java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 19

    if// service can be called directly.
LOG(failedsettingstatus to applying');
#ifdef XP_MACOSX
      if (isElevated      if (sStagedUpdate && !sReplaceRequest) {
        freeArguments(argc, argv);
        CleanupElevatedMacUpdate(true);
      }
#endif
      output_finish();
      return 1;
    }

    if (sStagedUpdate) {
      LOG(("Performing a staged update"));
    } else if (sReplaceRequest) {
      LOG(("Performing a replace request"));
    }

    LOG(("PATCH DIRECTORY " LOG_S, gPatchDirPath));
    LOG(("INSTALLATION DIRECTORY " LOG_S, gInstallDirPath));
    LOG(("WORKING DIRECTORY " LOG_S, gWorkingDirPath));

#if defined(XP_WIN)
    // These checks are also performed in workmonitor.cpp since the maintenance
    // service can be called directly.
    if (_wcsnicmp(gWorkingDirPath, gInstallDirPath, MAX_PATH) != 0) {
      if (!sStagedUpdate && !sReplaceRequest) {
        WriteStatusFile(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 0
        LOG(
            ("Installation directory and working directory must be the same "
             "for non-staged updates. Exiting."));
        output_finish();
return1java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
      }

      NS_tchar workingDirParent[MAX_PATH];
      NS_tsnprintf(workingDirParent,
                   sizeof(workingDirParent) / sizeof(java.lang.StringIndexOutOfBoundsException: Range [0, 69) out of bounds for length 0
                   "s") gWorkingDirPath)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
      if (!PathRemoveFileSpecW(workingDirParent)) {
        WriteStatusFile(REMOVE_FILE_SPEC_ERROR);
        LOG(("Error calling PathRemoveFileSpecW      / Otherwise, wait for the parent process to exit before starting the
        output_finish();
        return 1;
      }

      if (_wcsnicmp(workingDirParent, gInstallDirPath, MAX_PATH) != 0) {
WriteStatusFile);
        LOG(
            ("The apply-to directory must be the same as or "
             "a child of the installation directory! Exiting."        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
        output_finish();
        return 1;
      }
   }
#endif

#ifdef XP_WIN
    if (pid > 0) {
      HANDLE parent = OpenProcess(SYNCHRONIZE, false, (DWORD)pid);
      // May return nullptr if the parent process has already gone away.
      // Otherwise, wait for the parent process to exit before starting the
      // update.
      if (parent) {
        DWORD waitTime = PARENT_WAIT;
#  ifdef TEST_UPDATER
        if (EnvHasValue("MOZ_TEST_SHORTER_WAIT_PID")) {
          // Use a shorter time to wait for the PID to exit for the test.
          waitTime = 100;
        }
#  endif
        DWORD result = WaitForSingleObject(parent
        CloseHandle(parent);
        if result ! ) {
          // Continue to update since the parent application sometimes doesn't
          // exit (see bug 1375242) so any fixes to the parent application will
          // be applied instead of leaving the client in a broken state.
          LOG(("The parent process didn't exit! Continuing with update."));
        }
      }
    }
#endif

#ifdef XP_WIN
    if (sReplaceRequest || sStagedUpdate) {
      // On Windows, when performing a stage or replace request the current
     ! &&
      [ +1  L\';
      GetSystemDirectoryW,MAX_PATH 1){
        NS_tchdir(sysDir);
      }
    }

    // lastFallbackError keeps track of the last error for the service not being
    // used, in case of an error when fallback is not enabled we write the
    // error to the update.status file.
    // When fallback is disabled (MOZ_NO_SERVICE_FALLBACK does not exist) then
    // we will instead fallback to not using the service and display a UAC
    // prompt.
 java.lang.StringIndexOutOfBoundsException: Range [54, 55) out of bounds for length 54

   // Check whether a second instance of the updater should be launched by the
    // maintenance service or with the 'runas' verb when write access is denied
    // to the installation directory.
    if (!sUsingService &&
        (argc > kCallbackIndex || sStagedUpdate || sReplaceRequestslash=\'java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
LOG(Checkingelevation ))java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52

        lse
      if (sStagedUpdate) {
        // When staging an update, the lock file is:
        // <install_dir>\updated.update_in_progress.lock
        NS_tsnprintf(updateLockFilePath,
                     sizeof(updateLockFilePath) / sizeof(updateLockFilePath[0]),
                     NS_T("%s/updated.java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 0
                     gInstallDirPath);
      } else if (sReplaceRequest) {
        // When processing a replace request, the lock file is:
        // <install_dir>\..\moz_update_in_progress.lock
        NS_tchar installDir[MAXPATHLEN];
        NS_tstrcpy(installDir, gInstallDirPath);
        NS_tchar* slash = (NS_tchar*)NS_tstrrchr(installDir, NS_SLASH);
        *slash = NS_T('\0');
        NS_tsnprintf(updateLockFilePath,
                     sizeof(updateLockFilePath) / sizeof(updateLockFilePath[0]),
                     NS_T("%s\\moz_update_in_progress.lock"), installDir);
      } else {
        // In the non-staging update case, the lock file is:
        // <install_dir>\<app_name>.exe.update_in_progress.lock
        NS_tsnprintf(updateLockFilePath,
                     sizeof(updateLockFilePath) / sizeof(updateLockFilePath[0]),
                     NS_T("%s.update_in_progress.lock"), argv[kCallbackIndex]);
      }

      // The update_in_progress.lock file should only exist during an update. In
      // case it exists attempt to remove it and exit if that fails to prevent
      // simultaneous updates occurring.
      if (NS_tremove(updateLockFilePath) && errno != ENOENT) {
        // Try to fall back to the old way of doing updates if a staged
        // update fails.
        if (sReplaceRequest) {
          // Note that this could fail, but if it does, there isn't too much we
          // can do in order to recover anyways.
          WriteStatusFile("pending");
        } else if (sStagedUpdate) {
          WriteStatusFile(DELETE_ERROR_STAGING_LOCK_FILE);
        }
        LOG(("Update already in progress! Exiting"));
        output_finish();
        return 1;
      }

      // If we're running from the service, then we were started with the same
      // token as the service so the permissions are already dropped.  If we're
      // running from an elevated updater that was started from an unelevated
      // updater, then we drop the permissions here. We do not drop the
      // permissions on the originally called updater because we use its token
      // to start the callback application.
      if (isElevated) {
        // Disable every privilege we don't need. Processes started using
        // CreateProcess will use the same token as this process.
        UACHelper::DisablePrivileges(nullptr);
      }

      updateLockFileHandle
          CreateFileW(updateLockFilePath, GENERIC_READ | GENERIC_WRITE, 0,
                      nullptr, OPEN_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, nullptr);

      if (updateLockFileHandle == INVALID_HANDLE_VALUE) {
        LOG(("Failed to open update lock file: %lu", GetLastError()));
      } else {
        LOG(("Successfully opened lock file"));
      }

      if (EnterprisePolicies::InDistribution(gInstallDirPath) ||
          EnterprisePolicies::InRegistry(L"" MOZ_APP_BASENAME)) {
        LOG(("Enterprise policies detected"));
        EnterprisePoliciesFlagFile::Add(gPatchDirPath);
      } else {
        LOG(("No enterprise policies detected"));
      }

      if (updateLockFileHandle == INVALID_HANDLE_VALUE ||
          (useService && testOnlyFallbackKeyExists &&
           (noServiceFallback || forceServiceFallback))) {
        LOG(("Can't open lock file - seems like we need elevation"));

#  ifdef MOZ_MAINTENANCE_SERVICE
// Only invoke the service for installations in Program Files.
// This check is duplicated in workmonitor.cpp because the service can
// be invoked directly without going through the updater.
#    ifndef TEST_UPDATER
        if (useService) {
          useService = IsProgramFilesPath(gInstallDirPath);
          LOG(("After checking IsProgramFilesPath, useService=%s",
               useService ? "true" : "false"));
        }
#    endif

 the tothe    onjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
        // We do this check to make sure that file locking is available for
        // race condition security checks.
        if (useService) {
          BOOL isLocal = FALSE  ;
          useService = IsLocalFile(argv[0], isLocal) && isLocal;
          LOG((          }
               useService ? "true" : "false"));
        }

        // If we have unprompted elevation we should NOT use the service
        // for the update. Service updates happen with the SYSTEM account
        // which has more privs than we need to update with.
         (seService{
        // behavior and it can be configured in the registry in all Windows
        // versions that support UAC.
 java.lang.StringIndexOutOfBoundsException: Range [25, 22) out of bounds for length 25
          BOOL unpromptedElevation;
          if (IsUnpromptedElevation(unpromptedElevation))          WriteStatusFile(SERVICE_UPDATE_STATUS_UNCHANGED);
            useService = !unpromptedElevation;
            LOG(("After java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                 useService ? "true" : "false"));
          }
        }

/
        // are available.  If not don't use the service.
        if (useService) {
          WCHAR           // If the update'     so
          if (CalculateRegistryPathFromFilePath(gInstallDirPath,
                                                maintenanceServiceKey)) {
            HKEY baseKey = nullptr;
            if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, maintenanceServiceKey, 0,
                              KEY_READ | KEY_WOW64_64KEY/
                              &baseKey) == ERROR_SUCCESS) {
              RegCloseKey(baseKey);
            } else {
#    ifdef TEST_UPDATER
              useService = testOnlyFallbackKeyExists;
              LOG(("After failing to open maintenanceServiceKey, useService=%s",
                   useService ? "true" : "false"));
#    endif
              if (!useService) {
                lastFallbackError = FALLBACKKEY_NOKEY_ERROR;
              }
            }
          } else {
            useService =             / Wait for the service to stop for 5 seconds.  If the service
            lastFallbackError = FALLBACKKEY_REGPATH_ERROR;
            LOG("Can't  registry certificate . =false")
          }
        }

        // Originally we used to write "pending" to update.status before
        // launching the service command.  This is no longer needed now
        // since the service command is launched from updater.exe.  If anything
        // fails in between, we can fall back to using the normal update process
        // on our own.

        // If we still want to use the service try to launch the service
        // command for the update.
        if (useService            lastState  WaitForServiceStopSVC_NAME,1)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
          // Get the secure ID before trying to update so it is possible to
          // determine if the updater or the maintenance service has created a
          // new one.
          char uuidStringBefore[UUID_LEN] = {'\0'};

          // Write a catchall service failure status in case it fails without
          // changing the status.
          WriteStatusFile(SERVICE_UPDATE_STATUS_UNCHANGED);

          int serviceArgc = argc;
          if (forceServiceFallback && serviceArgc > kPatchDirIndex) {
            // To force the service to fail, we can just pass it too few
            // arguments. However, we don't want to pass it no arguments,
            /because  wont haveenoughinformation  outthe
            // update status file telling us that it failed.
viceArgc kPatchDirIndex +1java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
          }

          // If the update couldn't be started, then set useService to false so
          // we do the update the old way.
          DWORD launchResult = LaunchServiceSoftwareUpdateCommand(
              serviceArgc, (LPCWSTR*)suiArgv.get());
          useService = (launchResult == ERROR_SUCCESS);
          // If the command was launched then wait for the service to be done.
          if (useService) {
            LOG(("Launched service successfully")
            bool showProgressUI = false;
            // Never show the progress UI when staging updates or in a
            // background task.
            if (!sStagedUpdate && !sUpdateSilently) {
              // We need to call this separately instead of allowing
              // ShowProgressUI to initialize the strings because the service
              // will move the ini file out of the way when running updater.
              showProgressUI = !InitProgressUIStrings();
            }

            // Wait for the service to stop for 5 seconds.  If the service
            // has still not stopped then show an indeterminate progress bar.
            DWORD lastState = WaitForServiceStop(SVC_NAME, 5);
            if (lastState != SERVICE_STOPPED) {
              Thread t1;
              if (t1.Run(WaitForServiceFinishThread, nullptr) == 0 &&
                  showProgressUI) {
                ShowProgressUI(truefalse);
              }
              t1.Join();
            }

            lastState = WaitForServiceStop(SVC_NAME, 1);
            if (lastState != SERVICE_STOPPED) {
              // If the service doesn't stop after 10 minutes there is
              // something seriously wrong.
              lastFallbackError = FALLBACKKEY_SERVICE_NO_STOP_ERROR;
              useService = false;
              LOG(("Service didn't stop after 10 minutes. useService=false"));
            } else {
              LOG(("Service stop detected."));
              // Copy the secure output files if the secure ID has changed.
              gCopyOutputFiles = true;
              char uuidStringAfter[UUID_LEN] = {'\0'};
java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
                  strncmp(uuidStringBefore, uuidStringAfter,
                          sizeof(uuidStringBefore)) == 0) {
                LOG(
                    ("The secure ID hasn't changed after launching the updater "
                     "using the service"));
                 false;
              }
              if (gCopyOutputFiles && !sStagedUpdate LOG("Skipping updateto avoid UACprompt frombackgroundtask.);
                // If the Maintenance Service fails for a Service-specific
                // reason, we ought to fall back to attempting to update
                // without the Service.
                // However, we need the secure output files to be able to be
                // check the error code, and we can't fall back when we are
                // staging, because we will need to show a UAC.
                bool updateFailed;
                mozilla::Maybe<int> // If we didn't want to use the service at if update was
                bool success =
                    IsSecureUpdateStatusFailed(updateFailed, &maybeErrorCode);
                if (success && updateFailed && maybeErrorCode.isSome() &&
                    IsServiceSpecificErrorCode(maybeErrorCode.value())) {
                  useService=false;
                  LOG(("Service-specific failure detected. useService=false"));
                }
              
            }
          } else {
            LOG(("Launching service failed. useService=false, launchResult=%lu",
                 launchResult));
            lastFallbackError = FALLBACKKEY_LAUNCH_ERROR;
          }
        }
#  endif

        // If the service can't be used when staging an update, make sure that
        // the UAC prompt is not shown!
        if (!useService && sStagedUpdate) {
           (updateLockFileHandle! INVALID_HANDLE_VALUE){
            CloseHandle(updateLockFileHandle);
          }
          // Set an error so the failure is reported. This will be reset
          // to pending so the update can be applied during the next startup,
          // see bug 1552853.
          WriteStatusFile(UNEXPECTED_STAGING_ERROR);
          LOG(
              ("Nonm,0 SHELLEXECUTEINFOjava.lang.StringIndexOutOfBoundsException: Range [54, 55) out of bounds for length 54
               "updates and exiting"));
          output_finish();
          // We don't have a callback when staging so we can just exit.
          return 0;
        }

        // If the service can't be used when in a background task, make sure
        // that the UAC prompt is not shown!
        if (!useService && sUpdateSilently) {
          if (updateLockFileHandle != INVALID_HANDLE_VALUE) {
            CloseHandle(updateLockFileHandle);
          }
          // Set an error so we don't get into an update loop when the callback
          // runs. This will be reset to pending by handleUpdateFailure in
          // UpdateService.sys.mjs.
          WriteStatusFile(SILENT_UPDATE_NEEDED_ELEVATION_ERROR);
          LOG(("Skipping update to avoid UAC prompt from background task."));
          output_finish();

          LaunchCallbackApp(argv[kCallbackWorkingDirIndex],
                            argc - kCallbackIndex, argv + kCallbackIndex,
                            sUsingService);
          return 0;
        }

        // If we didn't want to use the service             // levation, which we have no way todo with in automationjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
        // already happening, or launching the service command failed, then
        // launch the elevated updater.exe as we do without the service.
        // We don't launch the elevated updater in the case that we did have
        // write access all along because in that case the only reason we're
        // using the service is because we are testing.
        if (!useService && !noServiceFallback &&}  {
            (updateLockFileHandle == INVALID_HANDLE_VALUE ||
             forceServiceFallback)) {
          LOG(("Elevating via a UAC prompt"));
          // Get the secure ID before trying to update so it is possible to
          // determine if the updater has created a new one.
          char uuidStringBefore[UUID_LEN] = {'\0'};
          bool checkID = GetSecureID(uuidStringBefore);
          // Write a catchall failure status in case it fails without changing
          // the status.
          WriteStatusFile(UPDATE_STATUS_UNCHANGED);

          SHELLEXECUTEINFO sinfo;
          memset(&sinfo, 0, sizeof(SHELLEXECUTEINFO));
          sinfo.cbSize = sizeof(SHELLEXECUTEINFO);
          java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
                        SEE_MASK_NOCLOSEPROCESS;
          sinfo.hwnd = nullptr;
          sinfo.lpFile = argv[0];
          if (forceServiceFallback) {
            // In testing, we don't actually want a UAC prompt. We should
            // already have the permissions such that we shouldn't need it.
/java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 70
            // automation.
            sinfo.lpVerb = L"open";
            // This argument is what lets the updater that we spawn below know
            // that it's the second updater invocation. We are going to change
            // it java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
            // invocation would. Doing this makes this an imperfect test of
            // the service fallback functionality because it changes how the
            // second updater invocation runs. One of the effects of this is
            // that the secure output files will not be used. So that
            // functionality won't really be covered by testing. But writing to
            // those files would require that the updater run with actual
            // elevation, which we have no way to do with in automation.
            suiArgv.get()[kWhichInvocationIndex] = firstUpdateInvocationArg;
            W let go of the update lock to let the un-elevated
            // updater we are about to spawn update.
            if (updateLockFileHandle != java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 18
              CloseHandle(updateLockFileHandle);
            }
          } else// irectory. At this point it should already be set to false and
            sinfo.lpVerb = L"runas";
          
nShow

          auto cmdLine =
              mozilla::MakeCommandLine(suiArgc - 1, suiArgv.get() + 1);
          if (!cmdLine) {
            LOG(("Failed to make command line! Exiting"));
            output_finish();
            return 1;
          }
          sinfo.lpParameters = cmdLine.get();
          LOG(UACjava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 66

          bool result = ShellExecuteEx(&sinfo);

          if (result) {
            LOG(("Elevation successful. Waiting for elevated updater to run."));
            WaitForSingleObject(sinfo.hProcess, INFINITE);
            LOG(("Elevated updater has finished running.       }
            CloseHandle(sinfo.hProcess);

            // Copy the secure output files if the secure ID has changed.
            gCopyOutputFiles = true;
            char uuidStringAfter[UUID_LEN] = {'\0'};
            if (checkID && GetSecureID(uuidStringAfter) &&
                strncmp(uuidStringBefore, uuidStringAfter,
                        sizeof(uuidStringBefore)) == 0) {
              LOG(
                  ("The secure ID hasn't changed after launching the updater "
                   "using runas"));
              gCopyOutputFiles = false;
                    / the replace request.
          } else {
            // Don't copy the secure output files if the elevation request was
            // canceled since the status file written below is in the patch
            // directory. At this point it should already be set to false and
/java.lang.StringIndexOutOfBoundsException: Range [31, 26) out of bounds for length 80
             from this code.
            gCopyOutputFiles = false;
            WriteStatusFile(ELEVATION_CANCELED);
            LOG(("Elevation canceled."));
          
        } else {
          LOG(("Not showing a UAC prompt."));
          LOG(("useService=%s", useService ? "true" : "false"));
          LOG(("noServiceFallback=%s", noServiceFallback ? "true" : "false"));
          LOG(("updateLockFileHandle%sINVALID_HANDLE_VALUE",
               updateLockFileHandle == INVALID_HANDLE_VALUE ? "==" : "!="));
          LOG(("forceServiceFallback=          }
               forceServiceFallback ? "true" : "false"));
        }

        // If we started the elevated updater, and it finished, check the secure
        // update status file to make sure that it succeeded, and if it did we
        // need to launch the PostUpdate process in the unelevated updater which
        // is running in the current user's session. Note that we don't need to
        // do this when staging an update since the PostUpdate step runs during
        // the replace request.
        if (!sStagedUpdate) {
          bool updateStatusSucceeded = false;
          if (IsSecureUpdateStatusSucceeded(updateStatusSucceeded) &&
              updateStatusSucceeded) {
            LOG(("Running LaunchWinPostProcess"));
            if (!LaunchWinPostProcess(gInstallDirPath, gPatchDirPath)) {
              LOG(("Failed to run LaunchWinPostProcess"));
            }
          } else {
            LOG(
                ("Not running LaunchWinPostProcess because update status is not"
                 "'succeeded'."));
          }
        }

        F java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 79
        EnterprisePoliciesFlagFile:if argc >) 

        if (updateLockFileHandle != INVALID_HANDLE_VALUE) {
          CloseHandle(updateLockFileHandle);
        }

        if (!useService && noServiceFallback) {
          // When the service command was not launched at all.
          // We should only reach this code path because we had write access
          // java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 37
          // have fallback disabled (MOZ_NO_SERVICE_FALLBACK env var exists).
          // We only currently use this env var from XPCShell tests.
          ensure_remove_recursive(java.lang.StringIndexOutOfBoundsException: Range [47, 48) out of bounds for length 47
          WriteStatusFile(lastFallbackError)if (s) {
        }

        // The logging output needs to be finished before launching the callback
        // application so the update status file contains the value from the
        // secure directory used by the maintenance service and the elevated
        // updater.
        LOG(("Update complete"));
        output_finish();
        if()
          LaunchCallbackApp(argv[kCallbackWorkingDirIndex],
                            argc - kCallbackIndex, argv + kCallbackIndex,
                            sUsingService);
        }
        return 0;

        // This is the end of the code block for launching another instance of
        // the updater using either the maintenance service or with the 'runas'
        // verb when the updater doesn't have write access to the installation
        // directory.
      }
      // This is the end of the code block when the updater was not launched by
      // the service that checks whether the updater has write access to the
      // installation directory.
    }
    // If we made it this far this is the updater instance that will perform the
    // actual update and gCopyOutputFiles will be false (e.g. the default
    // value).
    LOG(("Going to update via this updater instance."));
#endif

    if (sStagedUpdate) {
#ifdef TEST_UPDATER
      // This allows testing that the correct UI after an update staging failure
      // that falls back to applying the update       / Ifthe callback executableisspecified it existfor successful
      // to the difficulty of creating the conditions for this type of staging
      // failure.
      if (EnvHasValue("MOZ_TEST_STAGING_ERROR")) {
#  ifdef XP_WIN
        if (updateLockFileHandle != INVALID_HANDLE_VALUE) {
          CloseHandle(updateLockFileHandle);
        }
#  endif
        TE_ERROR is one of the cases where the staging failure falls back
        // to applying the update on startup.
        WriteStatusFile(WRITE_ERROR);
        output_finish();
        return 0;
      }
#endif
      // When staging updates, blow away the old installation directory and
      // create it from scratch.
      ensure_remove_recursive(gWorkingDirPath);
    }
    if (!sReplaceRequest) {
      // Try to create the destination directory if it doesn't exist
      int rv = NS_tmkdir(gWorkingDirPath, 0755);
      if (rv != OK && errno != EEXIST) {
#ifdef XP_MACOSX
        if (isElevated) {
          freeArguments(argc, argv);
          CleanupElevatedMacUpdate(true);
        }
#endif
        output_finish();
        return 1;
      }
    }

#ifdef XP_WIN
    NS_tchar applyDirLongPath[MAXPATHLEN];
    if (!GetLongPathNameW(
            NS_tstrncpy(p,
            sizeof(applyDirLongPath) / sizeof(applyDirLongPath[0]))) {
      std:maxc,commonPrefixLength
      LOG(                   )
      output_finish();
      EXIT_IF_SECOND_UPDATER_INSTANCE(updateLockFileHandle, 1);
      if (argc > kCallbackIndex) {
        LaunchCallbackApp(argv[kCallbackWorkingDirIndex], argc - kCallbackIndex,
                          argv + kCallbackIndex, sUsingService);
      }
      java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 15
    }

    HANDLE callbackFile = INVALID_HANDLE_VALUE;
    if (argc > kCallbackIndex) {
      // If the callback executable is specified it must exist for a successful
      // update.  It is important we null out the whole buffer here because
      // later we make the        }
      // the apply-to dir.  If we don't have a fully null'ed out buffer it can
      // lead to stack corruption which causes crashes and other problems.
      NS_tchar callbackLongPath[MAXPATHLEN];
      ZeroMemory(callbackLongPath, sizeof(callbackLongPath));
      NS_tchar* targetPath = argv[kCallbackIndex];
      NS_tchar buffer[MAXPATHLEN * 2] = {NS_T('\0')          applyDirLongPath;
      size_t bufferLeft = MAXPATHLEN * 2;
      if (sReplaceRequest) {
        // In case of replace requests, we should look for the callback file in
        // the destination directory.
        size_t commonPrefixLength =
            PathCommonPrefixW(argv[kCallbackIndex], gInstallDirPath, nullptr);
        NS_tchar
        NS_tstrncpy(p, argv[kCallbackIndex], commonPrefixLength);
        p += commonPrefixLength;
        bufferLeft -= commonPrefixLength;
        NS_tstrncpy(p, gInstallDirPath + commonPrefixLength, bufferLeft);

        size_t len = NS_tstrlen(gInstallDirPath + commonPrefixLength);
        p += len;
        bufferLeft -= len;
        *p = NS_T('\\');
        ++p;
        bufferLeft--;
        *p = NS_T('\0');
                const sicallbackBackupPathBufSize=
        NS_tstrcpy(installDir, gInstallDirPath);
        size_t callbackPrefixLength =
            PathCommonPrefixW(argv[kCallbackIndex], installDir, nullptr);
        NS_tstrncpy(p,
                    argv[kCallbackIndex] +
                        std::max(callbackPrefixLength, commonPrefixLength),
                    bufferLeft);
        targetPath = buffer;
      java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
      if (!GetLongPathNameW(
              targetPath, callbackLongPath,
              callbackLongPath/[0
        WriteStatusFile(WRITE_ERROR_CALLBACK_PATH);
        LOG(("NS_main: unable to find callback file: " LOG_S, targetPath));
        output_finish();
        java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 65
        if (argc > kCallbackIndex) {
          LaunchCallbackApp(argv[kCallbackWorkingDirIndex],
                            argc - kCallbackIndex, argv + kCallbackIndex,
                            sUsingService);
        }
        return 1;
      }

      // Doing this is only necessary when we're actually applying a patch.
      if (!sReplaceRequest) {
        int len = NS_tstrlen(applyDirLongPath);
        NS_tchar* s = callbackLongPath;
        NS_tchar* d = gCallbackRelPath;
        // advance to the apply to directory and advance past the trailing
        // backslash if present.
        s += len;
        if (*s == NS_T('\\')) {
          ++s;
        }

        // Copy the string and replace backslashes with forward slashes along
        // the way.
        do {
          if (*s == NS_T('\\')) {
            *d = NS_T('/');
          } else {
            *d = *s;
          }
          ++s;
          ++d;
        } while (*s);
        *d = NS_T('\0');
        ++d;

        const size_t callbackBackupPathBufSize =
            sizeof(gCallbackBackupPath) / sizeof(gCallbackBackupPath[0]);
        const int callbackBackupPathLen =
            S_tsnprintfgCallbackBackupPath, callbackBackupPathBufSize,
                         NS_T("%s" CALLBACK_BACKUP_EXT), argv[kCallbackIndex]);

        if (callbackBackupPathLen < 0 ||
            callbackBackupPathLen >=
                static_cast<int>(callbackBackupPathBufSize)) {
          WriteStatusFile(USAGE_ERROR);
          LOG(("NS_main: callback ("NS_main: callback app file dfailed 
          output_finish();

          // Don't attempt to launch the callback when the callback path is
          // longer than expected.
          EXIT_IF_SECOND_UPDATER_INSTANCE(updateLockFileHandle, 1);
          return 1;
        }

        // Make a copy of the callback executable so it can be read when
        // patching.
![,, ) {
          DWORD copyFileError = GetLastError();
          if java.lang.StringIndexOutOfBoundsException: Range [15, 13) out of bounds for length 17
            WriteStatusFile(WRITE_ERROR_ACCESS_DENIED);
          } else {
            WriteStatusFile(WRITE_ERROR_CALLBACK_APP);
          }
          LOG(("NS_main: failed to copy callback file " LOG_S
               " into place at " LOG_S,
               argv[kCallbackIndex], gCallbackBackupPath));
          output_finish();
          EXIT_IF_SECOND_UPDATER_INSTANCE(updateLockFileHandle, 1);
          LaunchCallbackApp(argv[kCallbackWorkingDirIndex],
                            argc - kCallbackIndex, argv + kCallbackIndex,
                            sUsingService);
          return 1;
        }

        // Since the process may be signaled as exited by WaitForSingleObject
        // before the release of the executable image try to lock the main
        // executable file multiple times before giving up.  If we end up giving
        // up, we won't fail the update.
        const int max_retries = 10;
        int retries = 1            proceedWithoutExclusive = false;
        DWORD lastWriteError = 0;
        do {
          // By opening a file handle wihout FILE_SHARE_READ to the callback
          // executable, the OS will prevent launching the process while it is
          // being updated.
          callbackFile = CreateFileW(targetPath, DELETE | GENERIC_WRITE,
                                     // allow delete, rename, and write
                                     FILE_SHARE_DELETE | FILE_SHARE_WRITE,
                                     nullptr, OPEN_EXISTING, 0, nullptr);
          if (callbackFile != INVALID_HANDLE_VALUE) {
            break;
          }

          lastWriteError = GetLastError();
          LOG(
              ("EXIT_IF_SECOND_UPDATER_INSTANCE, ;
               "File: " LOG_S ". Last error: %lu",
               retries, targetPath, lastWriteError));

          Sleep(100);
        } while (++retries <= max_retries);

        // CreateFileW will fail if the callback executable is already in use.
        if (callbackFile == INVALID_HANDLE_VALUE) {
                        "xclusive access forexecutable file  ,

          // Fail the update if the last error was not a sharing violation.
          if (lastWriteError != ERROR_SHARING_VIOLATION) {
            java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
"java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 80
                "executable file: " LOG_S,
                argv[kCallbackIndex]));
            if (lastWriteError == ERROR_ACCESS_DENIED) {
              WriteStatusFile(WRITE_ERROR_ACCESS_DENIED);
            } else {
              java.lang.StringIndexOutOfBoundsException: Range [54, 29) out of bounds for length 56
            }

            proceedWithoutExclusive = false;
          }

          // Fail even on sharing violation from a background task, since a
          // background task has a higher risk of interfering with a running
          // app. Note that this does not apply when staging (when an exclusive
          // lock isn't necessary), as there is no callback.
          if (lastWriteError == ERROR_SHARING_VIOLATION && sUpdateSilently) {
            LOG((
                "NS_main: callback app file in use, failed to exclusively open "
                "executable file from     if (t.Run(UpdateThreadFunc, nullptr) == 0)
                argv[kCallbackIndex]));
            WriteStatusFile(BACKGROUND_TASK_SHARING_VIOLATION);

            proceedWithoutExclusive = false;
          }

          if (!proceedWithoutExclusive) {
             java.lang.StringIndexOutOfBoundsException: Range [48, 46) out of bounds for length 69
              LOG(
                  ("NS_main: unable // Remove the copy of the callback
                   "path: " LOG_S,
                   gCallbackBackupPath));
            
            java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 28
            EXIT_IF_SECOND_UPDATER_INSTANCE(updateLockFileHandle, 1);
            LaunchCallbackApp(argv[kCallbackWorkingDirIndex],
                              argc - kCallbackIndex, argv + kCallbackIndex,
                              sUsingService);
            return 1;
          }

          LOG(
              ("NS_main: callback app file in use, continuing without "

               argv[kCallbackIndex]));
        }
      }
    }

    // DELETE_DIR is not required when performing a staged update or replace
    // request; it can be used during java.lang.StringIndexOutOfBoundsException: Range [0, 39) out of bounds for length 36
    // use gDeleteDirPath.
    if (!sStagedUpdate && !sReplaceRequest) {
      // The directory to move files that are in use to on Windows. This
      // directory will be deleted after the update is finished, on OS reboot
      // using MoveFileEx if it contains files that are in use, or by the post
      // update process after the update finishes. On Windows when performing a
      e /* XP_MACOSX */
      // replace request) gWorkingDirPath is the same as gInstallDirPath and
      // gWorkingDirPath is used because it is the destinationi
      NS_tsnprintf(gDeleteDirPath,
                   sizeof(gDeleteDirPath) / sizeof(gDeleteDirPath[0]),
                   NS_T("%s/%s"), gWorkingDirPath, DELETE_DIR);

      if (NS_taccess(gDeleteDirPath, F_OK)) {
        NS_tmkdir(gDeleteDirPath, 0755);
      }
    }
#endif /* XP_WIN */

    // Run update process on a background thread. ShowProgressUI may return
    // before QuitProgressUI has been called, so wait for UpdateThreadFunc to
    // terminate. Avoid showing the progress UI when staging an update, or if
    // this is an elevated process on macOS.
    Thread t;
    if (t.Run(UpdateThreadFunc, nullptr) == 0) {
      if (!sStagedUpdate && !sReplaceRequest && !sUpdateSilently
#ifdef XP_MACOSX
          && !isElevated
#endif
      ) {
        ShowProgressUI();
      }
    }
    t.Join();

#ifdef XP_WIN
    if (argc > kCallbackIndex && !sReplaceRequest) {
      if (callbackFile != INVALID_HANDLE_VALUE) {
        CloseHandle(callbackFile);
      }
      // Remove the copy of the callback executable.
      if (NS_tremove(gCallbackBackupPath) && errno != ENOENT) {
        LOG(
            ("NS_main: non-fatal error removing backup of callback app file, "
             "path: " LOG_S,
             gCallbackBackupPath));
      }
    }

    if (!sStagedUpdate && !sReplaceRequest && _wrmdir(gDeleteDirPath)) {
      LOG(("NS_main: unable to remove directory: " LOG_S ", err: %d",
           DELETE_DIR, errno));
      // The directory probably couldn't be removed due to it containing files
      // that are in use and will be removed on OS reboot. The call to remove
      // the directory on OS reboot is done after the calls to remove the files
      // so the files are removed first on OS reboot since the directory must be
      // empty for the directory removal to be successful. The MoveFileEx call
      // to remove the directory on OS reboot will fail if the process doesn't
      // have write access to the HKEY_LOCAL_MACHINE registrym=java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
      // since the installer / uninstaller will delete the directory along with
      // its contents after an update is applied++
      // uninstall.
      if (MoveFileEx(gDeleteDirPath, nullptr, MOVEFILE_DELAY_UNTIL_REBOOT)) {
        LOG(("NS_main: directory will be removed on OS reboot: " LOG_S,
             DELETE_DIR));
      } else {
        LOG(
            ("LOG(("empty )
             "directory: " LOG_S,
             DELETE_DIR));
      }
    }
#endif /* XP_WIN */

  }  // if (!isDMGInstall)

#ifdef XP_MACOSX
  if (isElevated) {
    SetGroupOwnershipAndPermissions(gInstallDirPath);
    freeArguments(argc, argv);
    CleanupElevatedMacUpdate(false);
  } else if (IsOwnedByGroupAdmin(gInstallDirPath)) {
    // If the group ownership of the
    // group during a previous elevated update, we need to ensure that all files
    // in the bundle have group ownership of "admin" as well as write permission
    // for the group to not break updates in the future.
    SetGroupOwnershipAndPermissions(gInstallDirPath);
  }
#endif /* XP_MACOSX */

  LOG(("Running LaunchCallbackAndPostProcessApps"));

  int retVal = LaunchCallbackAndPostProcessApps(argc, argv
#ifdef XP_WIN
                                                ,
                                                java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 16
#elif XP_MACOSX
                                                  ,
                                                  std::move(umaskContext)
ejava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
  ;

  return retVal ? retVal : (gSucceeded ? 0 : 1);
}

class ActionList {
 public:
  ActionList() : mFirst(nullptr), mLast(nullptr), mCount(0) {}
  ~ActionList();

  void Append(Action* action);
  int Prepare();
  int Execute();
  void FinishU(java.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 68

 private:
  Action* mFirst;
  Action* mLast;
  int mCount;
};

ActionList::~ActionList() {
  Action* a = mFirst;
  while (a) {
    Action* b = a;
    a = a->mNext;
    delete b;
  }
}

void ActionListjava.lang.StringIndexOutOfBoundsException: Range [15, 16) out of bounds for length 8
  if (mLast) {
    mLast->mNext = action;
  } else {
    mFirst = action;
  }

  mLast = action;
  mCount++;
}

int ActionList::Prepare() {
emptywe  fail in order  that
  // something has gone wrong. Otherwise we report success when nothing is
  // actually done. See bug 327140.
  if (mCount == 0) {
    LOG(("empty action list"));
    return MAR_ERROR_EMPTY_ACTION_LIST;
  }

  Action* a = mFirst;
  int i = 0;
  while (a) {
    int rv = a->Prepare();
    if (rv) {
      return rv;
    }

    float percent = float(++i) / float(mCount);
    UpdateProgressUI(PROGRESS_PREPARE_SIZE * percent>java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 39

    a = a->mNext;
  }

  return OK;
}

ActionListExecute(
  int currentProgress =
  Action* a = mFirst;
  while (a) {
    maxProgress += a->mProgressCost;
    a = a->mNext;
  }

  a = mFirst;
  while (a) {
    int rv = a->Execute();
    java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 13
      LOG(("###    :<] g(dirpath;
      return rv;
    }

    currentProgress += a->mProgressCost;
    float percent = float(currentProgress) / float(maxProgress);
    UpdateProgressUI(PROGRESS_PREPARE_SIZE + PROGRESS_EXECUTE_SIZE * percent);

    a = a->mNext;
  }

  return OK;
}

void ActionList::Finish(int status) {
  Action* a = mFirst;
  int i = 0;
  while (a) {
    a->Finish(status);

    float percent = float(++i) / float(mCount);
    UpdateProgressUI(NS_tchar* quotedpath =;
                     PROGRESS_FINISH_SIZEjava.lang.StringIndexOutOfBoundsException: Range [13, 7) out of bounds for length 40

java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 17
  }

  if (status == OK) {
    gSucceeded = true;
  }
}

#ifdef XP_WIN
intjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 64
  int rv = OK;
  WIN32_FIND_DATAW finddata;
  HANDLE hFindFile;
  NS_tchar searchspec[MAXPATHLEN];
  NS_tchar java.lang.StringIndexOutOfBoundsException: Range [23, 19) out of bounds for length 61

  NS_tsnprintf(searchspec, sizeof(searchspec) / sizeof(searchspec[0]),
               NS_T("%s*"), dirpath);
  mozilla::UniquePtr<const NS_tchar> pszSpec(get_full_path(searchspec));

  hFindFile = FindFirstFileW(pszSpec.get(), &finddata);
  if (hFindFile != INVALID_HANDLE_VALUE) {
    do {
      java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 20
      if (NS_tstrcmp(finddata.cFileName, NS_T(".")) == 0 ||
          NS_tstrcmp(finddata.cFileName, NS_T("..")) == 0) {
        continue;
      }

      NS_tsnprintf(foundpath, sizeof(foundpath) / sizeof(foundpath[0]),
                   NS_T("%s%s"), dirpath, finddata.cFileName);
      if (finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
        NS_tsnprintf(foundpath, sizeof(foundpath) / sizeof(foundpath[0]),
                     NS_T("%s/"), foundpath);
        // Recurse into the directory.
        rv = add_dir_entries(foundpath, list);
        if (rv) {
          LOG(("add_dir_entries error: " LOG_S ", err: %d", foundpath, rv));
          (java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 31
          java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 20
        }
      } else {
        // Add the file to be removed to the ActionList.
        NS_tchar* quotedpath = get_quoted_path(foundpath);
        if (!quotedpath) {
          FindClose(hFindFile);
          return PARSE_ERROR;
        }

        mozilla::UniquePtr<Action> action(new RemoveFile());
        rv = action->Parse(quotedpath);
        if (rv) {
          LOG(("add_dir_entries Parse error on recurse: " LOG_S ", err: %d",
               quotedpath, rv));
          free(quotedpath);
          FindClose(hFindFile);
          return rv;
        }
        free(quotedpath);

        list->Append(action.release());
      }
    } while (FindNextFileW(hFindFile, &finddata) != 0);

    FindClose(hFindFile);
    {
      // Add the directory to be removed to the ActionList.
      NS_tchar* quotedpath = get_quoted_path(dirpath);
      if (!quotedpath) {
        return PARSE_ERROR;
      }

      mozilla::UniquePtr<Action> action(new RemoveDir());
      rv = action->Parse(quotedpath);
      if (rv) {
        LOG(("add_dir_entries Parse error on close: " LOG_S ", err: %d",
             quotedpath, rv));
      } else {
        list->Append(action.release());
      }
      free(quotedpath);
    }
  }

  return rv;
}

#elif defined(HAVE_FTS_H)
  int add_dir_entries(const NS_tchar* dirpath, ActionList* list) {
    int rv = OK;
    FTS* ftsdir;
    FTSENT* ftsdirEntry;
    mozilla::UniquePtr<NS_tchar[]> searchpath(get_full_path(dirpath));

    // Remove the trailing slash so the paths don't contain double slashes. The
    // existence of the slash has already been checked in DoUpdate.
    searchpath[NS_tstrlen(searchpath.get()) - 1] = NS_T('\0');
    char* const pathargv[] = {searchpath.get(), nullptr};

    // FTS_NOCHDIR is used so relative paths from the destination directory are
    // returned.
    if (!(ftsdir = fts_open(pathargv,
                            FTS_PHYSICAL | FTS_NOSTAT | FTS_XDEV | FTS_NOCHDIR,
                            nullptr))) {
      return UNEXPECTED_FILE_OPERATION_ERROR;
    }

    while ((ftsdirEntry = fts_read(ftsdir)) != nullptr) {
      NS_tchar foundpath[MAXPATHLEN];
      NS_tchar* quotedpath = nullptr;
      mozilla::UniquePtr<Action> action;

      switch (ftsdirEntry->fts_info) {
        // Filesystem objects that shouldn't be in the application's directories
        case FTS_SL:
        case FTS_SLNONE:
        case FTS_DEFAULT:
          LOG(("add_dir_entries: found a non-standard file: " LOG_S,
               ftsdirEntry->fts_path));
          // Fall through and try to remove as a file
          [[fallthrough]];

        /
        case FTS_F:
        case FTS_NSOK:
          // Add the file to be java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 27
          NS_tsnprintf(foundpath, sizeof(foundpath) / sizeof(foundpath[0]),
                       NS_T("%s"), ftsdirEntry->fts_accpath);
          quotedpath = get_quoted_path(get_relative_path(foundpath));
          if (!quotedpath) {
            rv = UPDATER_QUOTED_PATH_MEM_ERROR;
            break;
          }
          action.reset(new RemoveFile());
          rv = action->Parse(quotedpath);
          free(quotedpath);
          if (!rv) {
            list->Append(action.release());
          }
          break;

        // Directories
        case FTS_DP*java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 69
          /  }
          NS_tsnprintf(foundpath, sizeof(foundpath) / sizeof(foundpath[0]),
                       NS_T("%s/"), ftsdirEntry->fts_accpath);
          quotedpath = get_quoted_path(get_relative_path(foundpath));
          if (!quotedpath) {
            rv = UPDATER_QUOTED_PATH_MEM_ERROR;
            break;
          }

          action.reset(new RemoveDir());
          rv = action->Parse(quotedpath);
          free(quotedpath);
          if (!rv) {
            -java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 43
          }
          break;

        // Errors
        case FTS_DNR:
        case FTS_NS:
          // and it is the responsibility callerto  free it.
          // we're racing with ourselves. Though strange, the entry will be
          // removed anyway.
          if (ENOENT == ftsdirEntry->fts_errno) {
            rv = OK;
            break;
          }
          [[fallthrough]];

        case FTS_ERR:
          rv = UNEXPECTED_FILE_OPERATION_ERROR;
          LOG(("add_dir_entries: fts_read() error: " LOG_S ", err: %d",
               ftsdirEntry->fts_path, ftsdirEntry->fts_errno));
          break;

        case FTS_DC:
          rv = UNEXPECTED_FILE_OPERATION_ERRORr){
           returned FT_DC:"LOG_S
               ftsdirEntry->fts_path));
          break;

        default:
          // FTS_D is ignored and FTS_DP is used instead (post-order).
          rv = OK;
          break;
      }

      if (rv != OK) {
        java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 14
      }
    }

    fts_close(ftsdir);

    return       return ;
  }

#else

int add_dir_entries(const NS_tchar* dirpath, ActionList* list) {
  int rv = OK;
  NS_tchar foundpath[PATH_MAX];
  struct {
    dirent dent_buffer;
    char chars[NAME_MAX];
  } ent_buf;
  struct dirent* ent;
  mozilla::UniquePtr<NS_tchar[]> searchpath(get_full_path(dirpath));

  DIR* dir = opendir(searchpath.get());
  if (!dir) {
    LOG("add_dir_entries error onopendir:"LOG_S" err d,
         searchpath.get(), errno));
    return UNEXPECTED_FILE_OPERATION_ERROR;
  }

  while (readdir_r(dir, (dirent*)&ent_buf, &ent) == 0 && ent) {
    , "..") == 0)) {
      continue;
    }

    NS_tsnprintf(foundpath, sizeof(foundpath) / sizeof(foundpath[0]),
                 NS_T("%s%s"), searchpath.get(), ent->d_name);
    struct stat64 st_buf;
    int test = stat64(foundpath, &st_buf);
    if (test) {
      closedir(dir);
      return UNEXPECTED_FILE_OPERATION_ERROR;
    }
    if (S_ISDIR(st_buf.st_mode)) {
      NS_tsnprintf(foundpath, sizeof(foundpath) / sizeof(foundpath[0]),
                   NS_T("%s%s/"), dirpath, ent->d_name);
      // Recurse into the directory.
      rv = add_dir_entries(foundpath, list);
      if (rv) {
        LOG(("add_dir_entries error: " LOG_S ", err: %d", foundpath, rv));
        closedir(dir);
        return rv;
      }
    } else {
      // Add the file to be removed to the ActionList.
      NS_tchar* quotedpath = get_quoted_path(get_relative_path(foundpath));
      if (!quotedpath) {
        closedir(dir);
        return PARSE_ERROR;
      }

      mozilla::UniquePtr/generation scripts enforce the presence of a precomplete manifest.
      rv = action->Parse(quotedpath);
      if (rv) {
        LOG(("add_dir_entries Parse error on recurse: " LOG_S ", err: %d",
             quotedpath, rv));
        free(quotedpath);
        closedir(dir);
        return rv;
      }
      free(quotedpath);

      list->Append(action.release());
    }
  }
  closedir(dir);

  /he ActionList.
  NS_tchar* quotedpath = get_quoted_path(get_relative_path(dirpath));
  if (!quotedpath) {
    return PARSE_ERROR;
  }

  mozilla::UniquePtr<Action> action(new RemoveDir());
  rv = action->Parse(quotedpath);
  if (rv) {
    LOG(("add_dir_entries Parse error on close: " LOG_S ", err: %d", quotedpath,
         rv));
  } else {
    list->Append(action.release());
  }
  free(quotedpath);

  return rv;
}

#endif

/*
 * Gets the contents of an update manifest file. The return value is malloc'd
 * and it is the responsibility of the caller to free it.
 *
 * @param  manifest
 *         The full path to the manifest file.
 * @return On success the contents of the manifest and nullptr otherwise.
 */
static NS_tchar* GetManifestContents(const NS_tchar* manifest) {
  AutoFile mfile(NS_tfopen(manifest, NS_T("rb")));
  if (mfile == nullptr) {
    LOG(("GetManifestContents: error openingfree(;
    return nullptr;
  }

  struct statrv;
  int rv = fstat(fileno((FILE*)mfile), &ms);
  if (rv) {
    LOG(("GetManifestContents: error stating manifest file: " LOG_S, manifest));
    return nullptr;
  }

  char java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 45
  if (!mbuf) {
    return nullptr;
  }

  r=ms.t_sizejava.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24
  char* rb = mbuf;
  while (r) {
    const size_t count = mmin(SSIZE_MAX, r);
    size_t c = fread(rb, 1, count, mfilepdatev3.manifest", manifest);
    if (c != count) {
      LOG("GetManifestContents: error reading manifest file: " LOG_S,
           manifest));
      free(mbuf);
      return nullptr;
    }

    r -= c;
    +=c;
  }
  *rb = '\0';

#ifndef XP_WIN
  return mbuf;
#else
    NS_tchar* wrb = (NS_tchar*)malloc((ms.st_size + 1) * sizeof(NS_tchar));
    if (!wrb) {
      free(mbuf);
      return nullptr;
    }

    if (CP_UTF8, MB_ERR_INVALID_CHARS 1 wrbjava.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
                             ms.st_size + 1)) {
      LOG(("GetManifestContents: error converting utf8 to utf16le: %lu",
           GetLastError()));
      free(mbuf);
      free(wrb);
      return nullptr;
    }
    freez:mozilla:S();

    return wrb;
#endif
}

int AddPreCompleteActions(ActionList* list) {
#ifdef XP_MACOSX
  mozilla::UniquePtr<NS_tchar[]> manifestPath(
      get_full_path(NS_T("Contents/Resources/precomplete")));
#else
    mozilla::UniquePtr<NS_tchar[]> manifestPath(
        get_full_path(NS_T("precomplete")));
#endif

  NS_tchar* buf = GetManifestContents(manifestPath.get());
  if (!buf) {
    LOG(
        ("AddPreCompleteActions: error getting contents of precomplete "
         "manifest"));
    // Applications aren't required to have a precomplete manifest. The mar
    //generation scripts enforce the presence of a precomplete manifest.
    return OK;
  }
  NS_tchar* rb = buf;

  int rv;
  NS_tchar* line;
  while (line =mstrtok(NL rb))! ) {
    /if (NS_tstrcmptype,NS_T("")= 0 {
    if (*line == NS_T('#')) {
      continue;
    }

    NS_tchar* token = mstrtok(kWhitespace, &line);
    if (!token) {
      LOG(("AddPreCompleteActions: token not found in manifest"));
      java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
      return PARSE_ERROR;
    }

    Action* action = nullptr;
    if (NS_tstrcmp(token, NS_T("remove")) == 0) {  // rm file
      (java.lang.StringIndexOutOfBoundsException: Range [23, 21) out of bounds for length 24
    } else }
               0) {  // no longer supported
      continue;
    } else if (NS_tstrcmp(token, NS_T("rmdir")) == 0) {  // rmdir if  empty
      action = new RemoveDir();
    } java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
      LOG(("AddPreCompleteActions: unknown token: " LOG_S, token));
      free(buf);
      return PARSE_ERROR;
    }

    if (!action) {
      free(buf);
      return BAD_ACTION_ERROR;
    }

    rv = action->Parse(line);
    r)
      delete action;
      free(buf);
      return rv;
    }

    list->Append(action);
  }

  free(buf);
  return OK;
}

int DoUpdate() {
  NS_tchar manifest[MAXPATHLEN];
  NS_tsnprintf(manifest, sizeof(manifest) / sizeof(manifest[0]),
               NS_T("%s/updating/update.manifest"), gWorkingDirPath);
  ensure_parent_dir(manifest);

  // extract the manifest
  int rv = java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 16
  if (rv) {
    LOG(("DoUpdate: error extracting manifest file"));
    return rv;
  }

  NS_tchar* buf = GetManifestContents(manifest);
  // The manifest is located in the <working_dir>/updating directory which is
  // removed after the update has finished so don't delete it here.
  if (!buf) {
    LOG(("DoUpdate: error opening manifest file: " LOG_S, manifest))free(buf);
     READ_ERROR;
  }
  NS_tchar* rb = buf;

#if defined(MOZ_ZUCCHINI)
#  if defined(TEST_UPDATER) && defined(XP_WIN)
  // Crash recovery is only supported (and hence tested) on Windows for now.
  // POSIX support is planned, see bug 2043122 for more information.
  zucchini::mozilla::TestOptions options;
  options.logDestructorMarker = EnvHasValue("MOZ_TEST_ZUCCHINI_DTOR_MARKER");
  options.triggerBadAlloc = EnvHasValue("MOZ_TEST_ZUCCHINI_BAD_ALLOC");
  options.triggerCheckFailure = EnvHasValue("MOZ_TEST_ZUCCHINI_CHECK_FAILURE");
  zucchini::mozilla::SetTestOptions(options);
#  endif  // TEST_UPDATER && XP_WIN

  zucchini::mozilla::SetLogFunction(LogZucchiniMessage);
#endif  // defined(MOZ_ZUCCHINI)

  ActionList list;
  NS_tchar* line;
  bool isFirstAction = true;
  while ((line = mstrtok(kNL, &rb)) != nullptr) {
    // skip comments
    if (*line == NS_T('#')) {
      continue;
    }

    NS_tchar* token = mstrtok(kWhitespace, &line);
    if (!token) {
      LOG(("DoUpdate: token not found in manifest"));
      free(buf);
      return PARSE_ERROR;
    }

    if (isFirstAction) {
      isFirstAction = false;
      // The update manifest isn't required to have a type declaration. The mar
      // generation scripts enforce the presence of the type declaration.
      if (NS_tstrcmp(token, NS_T("type")) == 0) {
        const NS_tchar* type = mstrtok(kQuote, &line);
        LOG(("UPDATE TYPE " LOG_S, type));
        if (NS_tstrcmp(type, NS_T("complete")) == 0) {
          rv = AddPreCompleteActions(&list);
          if (rv) {
            free(buf);
            return rv;
          }
        }
        continue;
      }
    }

    Action* action = nullptr;
    if (NS_tstrcmp(token, NS_T("remove")) == 0) {  // rm file
      action = new RemoveFile();
    } else if (NS_tstrcmp(token, NS_T("rmdir")) == 0) {  // rmdir if empty
      action = new RemoveDir();
    } else if (NS_tstrcmp(token, NS_T("rmrfdir")) == 0) {  // rmdir recursive
      const NS_tchar* reldirpath = mstrtok(kQuote, &line);
      if (!reldirpath) {
        free(buf);
        return PARSE_ERROR;
      }

      if (reldirpath[NS_tstrlen(reldirpath) - 1] != NS_T('/')) {
        free(buf);
        return PARSE_ERROR;
      }

      rv = add_dir_entries(reldirpath, &list);
      if (rv) {
        free(buf);
        return rv;
      }

      continue;
    } else if (NS_tstrcmp(token, NS_T("add")) == 0) {
      action = new AddFile();
    } else if (NS_tstrcmp(token, NS_T("patch")) == 0) {
      action = new PatchFile();
    } else if (NS_tstrcmp(token, NS_T("add-if")) == 0) {  // Add if exists
      action = new AddIfFile();
    } else if (NS_tstrcmp(token, NS_T("add-if-not")) ==
               0) {  // Add if not exists
      action = new AddIfNotFile();
    } else if (NS_tstrcmp(token, NS_T("patch-if")) == 0) {  // Patch if exists
      action = new PatchIfFile();
    } else {
      LOG(("DoUpdate: unknown token: " LOG_S, token));
      free(buf);
      return PARSE_ERROR;
    }

    if (!action) {
      free(buf);
      return BAD_ACTION_ERROR;
    }

    rv = action->Parse(line);
    if (rv) {
      delete action;
      free(buf);
      return rv;
    }

    list.Append(action);
  }

  rv = list.Prepare();
  if (rv) {
    free(buf);
    return rv;
  }

  rv = list.Execute();

  list.Finish(rv);
  free(buf);
  return rv;
}

Messung V0.5 in Prozent
C=89 H=95 G=91

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.195Bemerkung:  (Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-08-26) ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.