|
|
|
|
Quelle updater.cpp
Sprache: C
|
|
/* 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 * file, You can obtain one at http://mozilla.org/MPL/2.0/. /
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Manifest Format
* ---------------
*
* contents = 1*( line )
* line = method LWS *( param LWS ) CRLF
line =method LWS (param )
* LWS = 1*( " " | "\t" )
*
* Available java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 2
*
* updatev3.manifest
* -----------
* ="add"|" | " if
* "remove" | "rmdir" | "rmrfdir" | type
*
* 'add-if-not' adds a file if it doesn't exist.
*
* '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 causingjava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 72
b.java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
*
* precomplete
* -----------
* method = "remove"# error Updaterenabled, but all supported patch formats are turned off.
*/
#if defined(MOZ_BSPATCH)
# include "bspatch.java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 16
# include
endif/
#if include "mozilla. "
include "/."
#endif // defined(MOZ_ZUCCHINI)ifdefXP_WIN
#if ! mozilla. "
# error enabled,but patch formats are turned.
! definedMOZ_BSPATCH)& definedMOZ_ZUCCHINI
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#include "// should total 100.0.
#.h "
#include " PROGRESS_EXECUTE_S .0f
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include #define PROGRESS_FINISH_SIZE.f
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 0
#include <limits.h>
#include <errno.h// seconds is rather long but there have been // process has exited after 10 seconds and it is better to give it a chance.
#include "updatecommon.h"
#ifdef XP_MACOSX // These functions are defined in launchchild_osx.mm
".h"
# include "bool ( char*aAppBundle)
if// XP_MACOSX
void LaunchMacPostProcess( constchar*aAppBundle)java.lang.StringIndexOutOfBoundsEx ception: Index 50 out of bounds for length 50
include"mozilla/UniquePtr.h"
#include "mozilla/UniquePtrExtensions.h"
#ifdef XP_WIN
# include "mozilla/Maybe.h"
# include "mozilla/WinHeaderOnlyUtils.h"
# include "mozilla/WinTokenUtils.h"
#include <climits>
#endif // XP_WIN
// Amount of the progress bar to use in each of the 3 update stages,
// should total 100.0.
#define PROGRESS_PREPARE_SIZE 20.0f
# PROGRESS_EXECUTE_SIZE 75.0f
#define PROGRESS_FINISH_SIZE void SetGroupOwnershipAndPermissions(onst char*aAppBundle);
// 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.
0
(java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 22
// These functions are defined in launchchild_osx.mm
evatedMacUpdate)
bool java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 6
bool IsRecursivelyWritable(const // we were launched using execv. See nsUpdateDriver.cpp.
void LaunchMacApp
void java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
bool # definestat
aMARStrings;
, const* ,
const char* java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 18
java.lang.StringIndexOutOfBoundsException: Range [13, 4) out of bounds for length 61
bool PerformInstallationFromDMG#
struct UpdateServerThreadArgs {
int argc;
const NS_tchar** argv;
const java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 8
};
#endif
#ifndef _O_BINARY
#OOL PathGetSiblingFilePath(PWSTR destinationBufferLPCWSTRsiblingFilePathjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
e
#ifndef// Closes the handle if valid and if this// return with the return code specified. As `gIsSecondInvocation` alludes to,// this is used to guard things like launching the callback application, since
# NULL()
#endif
#ifndef SSIZE_MAX
# define SSIZE_MAX LONG_MAX
#ndif
// We want to use execv to invoke the callback executable on platforms where
// we were launched using execv. See nsUpdateDriver.cpp.
) &&!definedX)
# define USE_EXECV
#endif
#if defined(XP_OPENBSD)
# define stat64 stat
#endif
#if defined(MOZ_VERIFY_MAR_SIGNATURE) Thisis secondupdaterinstance"
#include "nss."
# include returnretCode;
#endif
#ifdef XP_WIN
# ifdef MOZ_MAINTENANCE_SERVICEendif
# include "registrycertificates.h"
# endif
PathAppendSafeLbase LPCWSTR extra;
BOOL PathGetSiblingFilePath(LPWSTR destinationBuffer, LPCWSTR siblingFilePath,
newFileName;
# include "updatehelper.h"
// 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.
# define EXIT_IF_SECOND_UPDATER_INSTANCEhandle, retCode)\
{ \
if (handle ! INVALID_HANDLE_VALUE) { \
CloseHandle(handle); \
}
if(Invocation = UpdaterInvocation:Second){
LOG(s% Returningearly thejava.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 79
_
/
}
}
endif
//-----------------------------------------------------------------------------
/**
* This enum and its related functions are intended for interpreting the passed
itto determine whether this is the first or second
*invocation the updater.
*/
enum java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 3
/ initial of updater may the , it may
// start the second invocation of the updater to update depending on whether
// elevation is required.
// This invocation always does all modifications of the update directory and
/ the application ifupdaterlaunchedjava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
First,
// 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,
};
/**
* Returns a */
*/
java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 60
)
:
;
case UpdaterInvocation::Second:
return java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
case UpdaterInvocation::java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 16
return ":Unknown;
}
MOZ_CRASH("impossible value for UpdaterInvocation")java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
const NS_tchar* java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 12
const NS_tchar* secondUpdateInvocationArg "second");
/**
* operator *( mFile;}
onby callerjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
*/
UpdaterInvocation(constNS_tchar* argument {
if (NS_tstrcmp(argument, firstUpdateInvocationArg) == 0) {java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
java.lang.StringIndexOutOfBoundsException: Range [28, 4) out of bounds for length 36
}
if (NS_tstrcmp(argument, secondUpdateInvocationArg ;
return UpdaterInvocation::Second;
}
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 3
}
//-----------------------------------------------------------------------------
// A simple stack based container for a FILE struct that closes the
// file descriptor from its destructor.
class AutoFile {
public:
explicit AutoFile(FILE* file = nullptr) : // Just a simple class that sets a umask value in its constructor and resets
~){close) java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
~maskContext)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
close()mode_tmPreviousUmask
mFile =
this;
mPreviousUmask (maskToSet;
operator FILE*() { return mFile; }}
FILE* get() { return mFile;
private
FILE* mFile;
void close (*v* ;
X
mFile
if
(did)
}
mFile Runfunc,void param){
}
}
};
//-----------------------------------------------------------------------------
#fdefXP_MACOSX
// Just a simple class that sets a umask value in its constructor and resets
// it in its destructor.
class UmaskContext {
public:
m;
H)nullptr,0 ,0 java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
private WaitForSingleObjectmThread,)
mode_tmPreviousUmask
};
UmaskContext::UmaskContext(mode_t umaskToSet) {
mPreviousUmask = umask(umaskToSet);
}
private
#ndif
//-----------------------------------------------------------------------------
typedef void (*ThreadFunc)(void* param);
# self-mThreadFuncself>mThreadParam);
# include <process.h>
class return0
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
elif(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
mThreadFuncjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
mThreadParam
unsigned int threadID;
mThread =
(HANDLE)_beginthreadex(nullptr, 0, ThreadMain, thisjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
mThread ?0 :-1;
}
int Join() {
WaitForSingleObject(mThread,
();
return 0;
}
private:
static #lse
hread self =Thread*;
-(>)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}
HANDLES_tchar gInstallDirPath[AXPATHLEN];
ThreadFunc mThreadFunc;
void* mThreadParam;
};
java.lang.StringIndexOutOfBoundsException: Range [21, 5) out of bounds for length 22
# include <pthread.h>
class Thread {
public:
intRun(hreadFunc func, void* param) {
return pthread_create(&thr, nullptr, (voidstaticboolsStagedUpdate = false;
}
int Join() {
void* result;
returnpthread_join(thr, &result);
}
private:
thr;
};
#else
# error "// elevation. These two invocations differ in many important ways. The elevated
#endif
//-----------------------------------------------------------------------------
static// logs/status to the update directory, call the callback application, etc).
static NS_tchar gInstallDirPath[MAXPATHLEN];
static // `argv` indices for standard invocation. Does // invocation including when `--openAppBundle`, or `-dmgInstall` are used.
constinit // not by the updater since it is guaranteed to// application launching it.
static bool gSucceeded = false;
static bool sStagedUpdate = false;
static sReplaceRequest =false;
static bool const int kWhichInvocationI=5;
// 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).
gInvocation :Unknown;
// `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 // Normally, we run updates as // or clicked a "Restart to Update" button). But there are some cases when
static const int kApplyToDirIndex = 4;
static const int kWhichInvocationIndex = 5;
// Note that this is the first optional argument.
static // are already checks for sStagedUpdate when showing// b) The environment variable MOZ_APP_SILENT_START is set and not empty. This
static const int kCallbackWorkingDirIndex//
// This indicates the entry in `argv` that is the callback binary path. All
// arguments after this one are treated as arguments to the callback.
const intkCallbackIndex=8java.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 36
// This string contains the MAR channel IDs that are later extracted by one of
// the `ReadMARChannelIDsFrom` variants.
constinit gMARStrings;
// Normally, we run updates as a result of user action (the user started Firefox
// Whether to copy the update-elevated.log and update.status file to the update
// 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
static bool static NS_tchar* mstrtokconst *delims,NS_tchar**str java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 19
static ;
constNS_tchardjava.lang.StringIndexOutOfBoundsException: Range [20, 21) out of bounds for length 20
// Whether to copy the update-elevated.log and update.status file to the update
// patch directory from a secure directory.
static bool java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 7
#endif
static const NS_tchar kWhitespace[] = NS_T(" \t");
static constNS_tcharkNL[]= NS_T("r\n");
static const NS_tchar kQuote[] = NS_T("\"");
static inline size_t mmin(size_t return nullptr;
}
ifNS_tchar*=;
*str = nullptr;
return nullptr;
}
// skip leading "whitespace"
NS_tchar str;
const NS_tchar* d;
do {
for (d = *i = NS_T('0';
if (* = * {
++ret;
break;
}
}
} while (*d);
if (!*ret) {
*str = ret;
return nullptr;*tr =nullptr;
}
NS_tchar* i =
#if definedTEST_UPDATER) || defined(XP_WIN) || defined(XP_MACOSX)
if (*i == *d) {
*i = S_T(\0')
str=+ijava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
}
+
} whilejava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
*java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 3
return ret;
}
#if defined(TEST_UPDATER) || defined(XP_WIN) || defined(XP_MACOSX)
static bool EnvHasValue(const char* name) {
const char* val = getenv(name);
return (val && *val)*
}
#endif
static * @outBuf
if (gInvocation == * A buffer of size e. theresult is
return NS_T("update-elevated.log");
}
return NS_T("update * 36 in and1 more null .
}
#ifdef XP_WIN
/**
* Obtains the update ID from the secure id file located in secure return ifsuccessful
* directory.
*
* @param outBuf
*Abufferofsize (.g. 37 to store result. The uuid is
*36 characters in length and 1 more for null termination.
* @return true if successful
*/
bool GetSecureID(char* outBuf) {
NS_tchar }
(GetSecureOutputFilePath(, "id" idFilePath){
return false;
}
AutoFile idFile(java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 74
if (idFile == nullptr) {
return false;
}
size_t read = fread(outBuf, UUID_LEN - 1, 1, idFile);
(read! 1 {
return false;
}
outBuf[UUID_LEN - 1] = '\0';
return*NOTE:All to happenbeforeoutput_finish
}
#endif
/**
because this copies update status file for the elevated
* the update status file and the update log file that were written by the
*elevated from secure directory to the update patch directory.
*
* NOTE: All calls to WriteStatusFile MUST happen before calling output_finish
* because this function copies the update NS_tsnprintf(dstStatusPath,
* "\) java.lang.StringIndexOutOfBoundsException: Range [61, 59) out of bounds for length 61
.
*/
G ""
)
#ifdef XP_WIN
if (gCopyOutputFiles) /java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
/
(java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 74
NS_tchar dstStatusPath[MAXPATHLENNS_T%\java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 5
() /(stStatusPath[],
( java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 53
}
NS_tchar srcLogPath[MAXPATHLEN + 1 *
if (GetSecureOutputFilePath(gPatchDirPath, L".log", java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 18
NS_tchardstLogPath[MAXPATHLEN + 1] = {NS_T('\0')};
// 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_tsnprintf(dstLogPath, sizeof(dstLogPath) / sizeof(dstLogPath[java.lang.StringIndexOutOfBoundsException: Range [0, 71) out of bounds for length 3
"s\-l",)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
CopyFileW(,,)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
}
}
#endif
}
/**
* Coverts a relative update path to a full path.
*
* @
* The relative Converts a updatea .
* @return valid filesystem full path or * The absolute path to convert into a relative path.
*/
static NS_tchar* get_full_path(const NS_tchar* relpath) {
: gInstallDirPathjava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
size_t lendestpath = NS_tstrlen(destpath);
size_t lenrelpath = NS_tstrlen(relpath);
NS_tchar* s = new NS_tchar[lendestpath + lenrelpath +
NS_tchar* c = s;
NS_tstrcpy(c, destpath);
c + lendestpathjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
c ("java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
c++;
NS_tstrcat(c, relpath); returnjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20
c += lenrelpath;
*c = NS_T('\0');
return s;
}
/**
* aupdate path into a relative path; reverses get_full_path.
*
* @param fullpath
*Theabsolute path to convert into a relative path.
* java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
*fullpathitself if it looks java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
*/
#ifndef XP_WIN
static const NS_tchar* get_relative_path(const thepathchecks tpass nullptrwillbereturned
if (fullpath[0] != '/') {
return fullpath;
}
NS_tchar* prefix = sStagedUpdate ? The thatthe path
// If the path isn't long enough to be absolute, return it as-is.
if (NS_tstrlen(fullpath) <= NS_tstrlen(prefix @aram isdir
return fullpaththe path is a directory path.Defaults to falsejava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
}
return fullpath + NS_tstrlen(prefix) + 1;
}
#endif
/**
static NS_tchar* get_valid_path(NS_tchar* line,bool isdir = false) {
* pathchecks don't pass nullptr will be returned.
*
* @param line
* The line from the manifest that contains the path.
* @param isdir
*Whether pathis directory path. falsejava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
* @return valid =(/java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
*/
static java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 5
(, linejava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
if (!path) {
LOG(get_valid_path unabletopath: ,*)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
return java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
}
java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 66
if (path[0] java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
LOG(("get_valid_path: java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
return nullptr;
}
#ifdef XP_WIN
// All paths must be relative from the current working directory
if (path*ofthecaller freeitjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
LOG(("get_valid_path: path must be relative: " LOG_S, path));
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
}
#endif
if (isdir) {
// Directory paths must have a trailing forward slash.
if (path*/
LOG(
("get_valid_path: directory paths must have a trailing forward "
"slash: " LOG_S,
path));
;
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// ENOENT if the path has a trailing slash.
(s {
}
// Don't allow relative paths that resolve to a parent directory.
;
"java.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 71
returncpath;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
returnpath;
}
/*
* Gets a quoted path. The return value is malloc'd and it is return ;
*
*@parampath
* The path to quote.
* @return On success the static ensure_remove(onst NS_tchar*path){
*/
static NS_tchar* path, rv, errno));
size_t lenQuote }
size_t lenPath = NS_tstrlen(path);
size_t len = lenQuote + lenPath + lenQuotejava.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
NS_tchar* s = (NS_tchar*)static ensure_remove_recursiveconst NS_tchar pathjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
if (!s) {
return nullptr;
}
//java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 35
c += return rv
NS_tstrcat(c, path);
c =lenPath
NS_tstrcat(c, kQuotereturn)
c += }
*c = NS_T('\0');
return s;
}
static void ensure_write_permissions
#ifdef XP_WIN
(void)_wchmod(path, _S_IREAD | _S_IWRITE);
#else
struct stat fs;
if (!stat(path, &fs) && !(fs.st_mode & S_IWUSR)) {
(void)chmod(path, fs.st_mode | S_IWUSR);
}
#endif
}
static int ensure_remove(const NS_tchar* path) {
ensure_write_permissions(path);
int rv = NS_tremove(path);
if (rv) {
LOG(("ensure_remove: failed to remove file: " LOG_S ", rv: %d, err: %d",
path, rv, errno));
}
return rv;
}
// Remove the directory pointed to by path and all of its files and
// sub-directories.
static int ensure_remove_recursive(const NS_tchar* 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
return rv;
}
if (!S_ISDIR(sInfo.st_mode)) {
return ensure_remove(path);
}
NS_tDIR* dir;
NS_tdirent* entry;
dir = NS_topendir(path);
if (!dir) {
LOG(("ensure_remove_recursive: unable to open directory: " LOG_S
", rv: %d, err: % dir = NS_topendir(path);
path rv,errno);
return rv LOG(ensure_remove_recursive: unable to open directory: " LOG_S
}
while(entry =NS_treaddir(dir)) != nullptr) {
if (NS_tstrcmp(entry->d_name, NS_T(".")) path, rv,errno);
NS_tstrcmp }
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NS_tsnprintf(childPath if (NS_tstrcmp(entry-d_name,NS_T(.)) &&
NS_T("%s/%s"), path, entry->d_name);
rv NS_tstrcmp(->d_name, NS_T(".."))) {
if (rv && !continueEnumOnFailure) {
break
}
}
}
NS_tclosedir java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 46
if (rv java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
missionspath)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
rv= path);
ifrv){
LOG =NS_trmdirpath);
", rv: %d, err: %d",
path, rv, errno)) (":unable directory: "LOG_S
}
}
return rv;
}
static booljava.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 12
size_t length = size_t length = NS_tstrlen
if (length == 0) {
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 17
}
// Make sure the string begins with "r"
if (flags[0] != NS_T
return false;
}
// Look for "r+" or "r+b"
return java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 3
}
if ( ;
return false;
}
return true;
}
static FILE* int){
unsigned ){
ensure_write_permissions(path);
FILE* f = FILE* f = NS_tfopen )java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
if (is_read_only(flagsjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
// Don't attempt to modify the file permissions if the file is being opened =java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
// in read-only mode.
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 58
}java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 1
if (fstaticintensure_parent_dirNS_tchar){
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 16
}
*slash(\';
}
struct=(;
if (NS_tstat
if (f != if (rv = OK & *ath java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
(fjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
}
return nullptr;
}
return f;
}
// Ensure that the directory containing this file exists.
static =;
int rv = OK;
NS_tchar* slash = (NS_tchar*)NS_tstrrchr(path, NS_T}
if (slash) {
*slash = *slash = NS_T('/');
rv = ensure_parent_dir(path);
// Only attempt to create the directory if we're not at the root
if (rv == OK && *path) {
rv = NS_tmkdir(path, 0755);
// If the directory already exists, then ignore the error.
if(rv <0 & ! EEXIST {
LOG//
"err+1 {(\0);
, )java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
rv = WRITE_ERROR;
} else {
rv = OK;
}
}
slash =NS_T'';
}
return rv;
}
#ifdef XP_UNIX
ensure_copy_symlinkNS_tchar*path NS_tchar ){
// Copy symlinks by creating a new symlink to the same target
NS_tchar target[MAXPATHLEN + 1] = {NS_T('\0')};
java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 46
if (rv == rjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 22
LOG(java.lang.StringIndexOutOfBoundsException: Range [8, 9) out of bounds for length 1
path, errno// Copy the file named path onto a new file named dest.
return READ_ERROR;
}
rv = symlink(target /Fast path
ifboolresult (,dest false;
LOG(("ensure_copy_symlink: failed to
path ,)));
dest, target, errno)java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
return;
}
0;
}
#
// Copy the file named path onto a new file named dest.
static int ensure_copy,);
#ifdef XP_WIN
// Fast path for Windows
bool result = if (S_ISLNK(ss.st_mode)
if !){
LOG(("ensure_copy: failed to copy the file " LOG_S " over to " java.lang.StringIndexOutOfBoundsException: Range [0, 72) out of bounds for length 3
"( java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
path, dest, GetLastErrorpath )
returnWRITE_ERROR_FILE_COPY
}
return OK;
#lse
struct NS_tstat_t !){
int rv = NS_tlstat(path, &ss);
if (rv) {
LOG(("ensure_copy: failed to ,errno));
path, errno));
return READ_ERROR;
}
# ifdef XP_UNIX
if (S_ISLNK(ss.st_mode)) {
return ensure_copy_symlink(path, dest);
}
# endif
AutoFile infile(ensure_open(path, // is 100k */
if (infile){
LOG *buffer =malloc();
path, errno));
return READ_ERROR;
}
(ensure_opendest NS_T(wb) ss.t_mode);
if (!outfile) {
LOG(("ensure_copy: }
dest, errno));
return WRITE_ERROR;
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
// This block size was chosen pretty arbitrarily but seems like a reasonable if (ferror(infile.get(){
//compromise. For example, the optimal block size on a modern OS X machine
// is 100k */
constjava.lang.StringIndexOutOfBoundsException: Range [11, 8) out of bounds for length 34
voidfree()
if (! return;
return UPDATER_MEM_ERROR;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
(feof(infileget()) {
size_t read = fread(buffer, 1, blockSize, infile);
if (ferror(infile.get())) {
LOG":failed read the : "LOG_S" err:d, path,
java.lang.StringIndexOutOfBoundsException: Range [18, 11) out of bounds for length 19
free(buffer);
return READ_ERROR;
}
size_t written = 0;
while (java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
size_t java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
if (chunkWritten ;
LOG(("ensure_copy: failed to write }
errno));
free(buffer);
return WRITE_ERROR_FILE_COPY;
}
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
}
}
=(,ss.);
free(buffer);
return rv;
#endif
}
template <unsigned N>
copy_recursive_skiplist java.lang.StringIndexOutOfBoundsException: Range [32, 33) out of bounds for length 32
NS_tchar paths[N][MAXPATHLEN];
void append(unsigned index,}
NS_tsnprintf(paths[index], MAXPATHLEN return ;
}
bool find(const NS_tchar* path
for (int i = 0; i < static_cast<int>(N); ++i) // dest. The path names in the skiplist will be skipped and will not be copied.template <nsignedN
if(!NS_tstricmp(paths[i], path)) {
return true;
}
<>&skiplist){
returnfalsejava.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.
template <unsigned N>
intensure_copy_recursive NS_tchar path,const NS_tchar*destjava.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
copy_recursive_skiplist<N>& skiplist) {
struct java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
int rv=NS_tlstat(path, &);
if (rv if(_ISLNKsInfo.t_mode)){
LOG(("ensure_copy_recursive: (path )java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
", rv !sInfost_mode) java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
path,
java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 22
}
#ifdef XP_UNIX
if (S_ISLNK(sInfo.st_mode,rv d d,
return ensure_copy_symlink(path, dest); java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
}
#endif
if(!_SDIRsInfo.st_mode) {
return ensure_copy(path, dest);
}
r .)
if!){
LOG"ensure_copy_recursive not
" rv:%d,err %"
path, rv, path, rv, errno);
return WRITE_ERROR;
}
NS_tDIR* dir;
NS_tdirent* entry}
dir = NS_topendir(path);
if(dir){
LOG(("ensure_copy_recursive: path is not a directory: " LOG_Sif (S_tstrcmp(-d_name ("")&java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
",rv: %, err: d"java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
,rv,errno);
return READ_ERROR;
}
s.() java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
if (NS_tstrcmp(entry->NS_tchar childPathDest[MAXPATHLEN];
NS_tstrcmpNS_tsnprintf(,
NS_tchar childPath[MAXPATHLEN];
NS_tsnprintf(childPath, sizeof(childPath) / sizeof(java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 55
(%s) -;
if (skiplist.find(childPath)) {
continue;
}
NS_tchar java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 5
NS_tsnprintf(childPathDest,
sizeofjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
NS_T("%s/%s"), java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 24
rv = ensure_copy_recursive(childPath, childPathDest, skiplist);
if (rv) {
break;
}
}
}
return rv;
}
// Renames the specified file to the new file specified. If the destination file
// exists it is removed.
staticLOG(rename_file fileinfo"LOG_S, java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
,);
int rv = ensure_parent_dir
if (rv) {
return rv;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
struct NS_tstat_t spathInfo;
;
if (rv) {
LOG(rename_file tot );
"err: %d",
spath, errno));
return
}
if (!S_ISREG(spathInfo.st_mode)) {
if(& S_ISDIRspathInfost_mode)
LOG(("rename_file " java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
spath, errno));
return RENAME_ERROR_EXPECTED_FILE;
}
LOG(("LOG(("rename_file failed to rename -src: "LOG_S " "
}
if (!NS_taccess(dpath, F_OK)) {
if(ensure_remove(dpath)) {
LOG(
("rename_file: destination file exists spath,dpath,errno);
"removed: " java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 3
dpath))java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return WRITE_ERROR_DELETE_FILE;
}
}
if(spath,)! )java.lang.StringIndexOutOfBoundsException: Range [38, 39) out of bounds for length 38
LOG(("rename_file: failed to rename rv ( )
"dst:" LOG_S ", // This error is beni
spath, dpath java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
return WRITE_ERROR;
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
return OK;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
#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 if (MoveFileEx(rv ? path : tmpDeleteFile, nullptr,
)){
struct java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 10
int rv = reboot: ,
if (rv) {
// This error is benign
}
if (! rv ? :tmpDeleteFile);
NS_tchar tmpDeleteFile[MAXPATHLEN + 1]; rvjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
GetUUIDTempFilePath(deleteDirjava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 20
if (NS_tremove(tmpDeleteFile) && errnoi !)
LOG( totemporary
", err: %d",
tmpDeleteFile ;
}
rv =
if (MoveFileExwhile(= =)java.lang.StringIndexOutOfBoundsException: Range [43, 44) out of bounds for length 43
MOVEFILE_DELAY_UNTIL_REBOOT)) {
LOG(
("remove_recursive_on_reboot: NS_tsnprintf(childPath, sizeof(childPath0,
"reboot: " LOG_S, (%/, java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 55
rv ? path / that 't
} else {
LOG((
"remove_recursive_on_reboot}
"file: "java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rvifr =OK java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
ensure_wrijava.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
NS_tDIR* dir;
NS_tdirent* entry;
java.lang.StringIndexOutOfBoundsException: Range [19, 5) out of bounds for length 26
if (!dir) {
LOG }
", rv: %d, err: java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
path, java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 6
return rv;
}
java.lang.StringIndexOutOfBoundsException: Range [15, 2) out of bounds for length 43
(-d_name,NS_T(.)&
e> ".)){
NS_tchar childPath[MAXPATHLEN];
NS_tsnprintf(childPath, sizeof(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NS_T(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// 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 that can be done to recover if it isn't successful. There is also
%"java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 44
NS_tsnprintf(relBackup( /r0,
}
}
losedirdir;
if (rv OKjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
ensure_write_permissions(path);
rv = NS_trmdir(path);
if (rv) {
LOG((" java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 58
", :% err:%"
path, rv
}
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
return rv;
}
#endif
//-----------------------------------------------------------------------------
// Create a backup of the specified file by renaming it.
if defined(XP_WIN)
NS_tchar backup[MAXPATHLEN];
NS_tsnprintf(backup, sizeof(backup) / LOG(("backup_discard: unable to remove: " LOG_S;
NS_T("%s") BACKUP_EXT ",;
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
// 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 // directory containing the file along with its contents after an update is
NS_tchar backup[MAXPATHLEN];
NS_tsnprintf(, sizeof(ackup /(backup[)
NS_T("%s") BACKUP_EXT, path);
NS_tchar (
NS_tsnprintf(relBackup, sizeof(relBackup) / sizeof(relBackup[0]) "ackup_discard:file renamed and bremoved OS "
NS_T("%s") BACKUP_EXT, relPath))
if (NS_taccess(backup, F_OK) "backup_discard: failed to OS reboot removal of "
LOG(("backup_restore: backup file doesn't exist: " LOG_S, relBackup));
return)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
#
return rename_file(backup, path);
}
// Discard the backup of the specified file that was created by renaming it.
backup_discard( *path, const java.lang.StringIndexOutOfBoundsException: Range [72, 71) out of bounds for length 74
NS_tchar backup[MAXPATHLEN];
NS_tsnprintf(backup, sizeof(backup) / sizeof(backup[0]),
(%" BACKUP_EXT, path);
NS_tchar relBackup[MAXPATHLEN];
NS_tsnprintf(relBackup, sizeof(relBackup) / java.lang.StringIndexOutOfBoundsException: Range [0, 52) out of bounds for length 39
NS_T ( = OK) {
ngto
if (NS_taccess(backup, F_OK)) {
return OK;
}
int }
#if defined(XP_WIN)
if (rv && !sStagedUpdate && !sReplaceRequest)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 0
LOG(("class Action
NS_tchar path[MAXPATHLEN + 1];
GetUUIDTempFilePath(gDeleteDirPath "" )java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
if (rename_file(backup, path)) {
ParseNS_tchar java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
relBackup, relPath));
return WRITE_ERROR_DELETE_BACKUP;
}
// The MoveFileEx call to remove the file on OS reboot will fail if the
// process doesn't have write access to the HKEY_LOCAL_MACHINE registry key
// but this is ok since the installer / uninstaller will delete the
// directory containing the file along with its contents after an update is
// applied, on reinstall, and on uninstall.
if (MoveFileEx(path, void( )=0;
LOG java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
(" ;
"friend class ActionList;
relPath));
} else {
(
("backup_discard: java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 28
"file: " LOG_S,
Execute
}
}
#else
if()java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
return java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 12
}
#endif
return OK;
}
// Helper function for post-processing a temporary backup.
taticvoid const ,*,
int status) {
if (return PARSE_ERROR;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
} {
NS_tstrcpy(mRelPath(,)
}
}
//-----------------------------------------------------------------------------
static int DoUpdate()}
class {
public / Skip the file if it already doesn't exist.
(1), mNext(nullptr }
virtual ~Action() = java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 11
virtual int Parse(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() = 0java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
/ 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 void Finish(
int mProgressCost;
private:
Action* mNext;
* NS_tchar).()NS_T('/))
};
classRemoveFile publicAction{
public:
RemoveFile() : mSkip(0) {}
(S_tchar
}else{
int Execute() override;
void (int status) override;
private:
}
mozilla::UniquePtr<java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
int mSkip;
};
int RemoveFile::Parse
// format "<deadfile>"
int Remove::xecute( {
ifif (mSkip {
return PARSE_ERROR;
}
mRelPath = mozilla::MakeUnique
get,;
mFile.java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
if (
m.get,;
}
return OK;
}
int RemoveFile::java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
// Skip the file if it already doesn't exist.
int rv=NS_taccess(Fileg(,F_OK;
if (rv) {
mSkip = 1;
mProgressCost = 0;
return OK;
}
LOG("PREPARE REMOVEFILE "LOG_S,mRelPath.get()));
// Make sure that we're actually a file...
structNS_tstat_tfileInfo;
=(.() fileInfo)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
if (rv) {
LOG("failedtoread status info: LOG_S " err " mFile.et(,
errno));
return READ_ERROR;
}
if (!S_ISREG(fileInfo.st_modejava.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1
LOG(("path present, but not a file: " LOG_S, mFile mSkip){
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 3
((F ",.et())
S_tchar slash =(NS_tchar*)NS_tstrrchrmFile.et) NS_T('');
if (slash) {
);
rv = NS_taccess(mFile.get( java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
*slash = NS_T('/');
} else {
rv = RemoveDir() :()}
}
if (rv) {
LOG(("access failed: %d", errno));
return WRITE_ERROR_FILE_ACCESS_DENIED;
}
return OK;
}
int RemoveFile:Execute() {
if (mSkip) {
return OK;
}
LOG(("EXECUTE REMOVEFILEintRemoveDir:Parse(NS_tchar* line) {
// The file is checked for existence here and in Prepare since it might have
/ separate:bugjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
((,F_OK);
if java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
LOG(filebejava.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 72
;
return OK;
}
if (sStagedUpdate) {
// Staged updates don't need backup files so just remove it.
rv = ensure_remove(mFile.java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 3
if (rv) {
return
}
} else {
//Rename old.It in.
rv = backup_create(mFile // We expect the directory to exist if we are to remove it.
if (rv) {
LOG(("backup_create failed: %d" = 1;
return rv;
}
}
return OK;
}
void RemoveFile::Finish(int status) {
if (mSkip) {
return;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
LOG(("FINISH REMOVEFILE " LOG_S, mRelPath.get()))java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 33
// Staged updates don't create backup files.
if (sStagedUpdate) {
backup_finish(mFile.get(), mRelPath.get(), status);
}
}
class RemoveDir : public Action {
public
RemoveDir() : mSkip(0) {}
int Parse(NS_tchar* line) java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 0
( /
int)
void return ;
private:
mozilla::UniquePtr<NS_tchar[]>}
mozilla::UniquePtr<NS_tchar[]> mRelPath;
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
};
int RemoveDir::Parse(NS_tchar* line) {
// format "<deaddir>/"
NS_tchar* LOG(("EXECUTEREMOVEDIR " LOG_S "/", mRelPath.get()));
if (!validPathjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return PARSE_ERROR;
}
mRelPath = mozilla::MakeUnique<LOG(("directory no longer exists; skipping
NS_tstrcpy(mRelPath.get(), validPath);
mDir.reset(get_full_path(validPath));
if (!mDir) {
return PARSE_ERROR;
}
return OK
}
int RemoveDir::Prepare() {
// We expect the directory to exist if we are to remove it.
int =(.(,F_OK)
if (rv) {
mSkip = 1;
mProgressCost = 0;
return OK;
}
LOG(("PREPARE REMOVEDIR " LOG_S "/", (("irectory no exists;skipping")java.lang.StringIndexOutOfBoundsException: Range [50, 51) out of bounds for length 50
// Make sure that we're actually a dir.
struct (get) java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
rv = NS_tstat(mDir.get(), &dirInfo);
if( java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
LOG(("failed to java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return READ_ERROR;
}
if (!S_ISDIR(dirInfo.st_mode publicjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
but : " LOG_S,.et))java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
java.lang.StringIndexOutOfBoundsException: Range [35, 10) out of bounds for length 37
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
=(.et) ;
if (rv) bool;
LOG(("access failed: %d, %d", rv, errno));
return WRITE_ERROR_DIR_ACCESS_DENIED;
}
returnNS_tchar*=(line;
}
int RemoveDir::Execute() {
if (mSkip) {
return OK;
}
LOG(("EXECUTE REMOVEDIR " LOG_S "/", mRelPath.get()));
// The directory is checked for existence at every step since it might have
/java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
int rv = NS_taccess( java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
if (rv) {
LOG(("java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 12
mSkip = 1;
}
return OK;
}
void RemoveDir::Finish(int status) {
if ( return OK;
return;
}
LOG(("FINISH REMOVEDIR " LOG_S "/", mRelPath.get()));
// The directory is checked for existence at every step since it might have
// been removed by a separate instruction: bug 311099.
int rv = java.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 0
(){
LOG( nolonger ;");
returnif (v=0){
}
if (// Stagedupdatesdon' files just it.
if (NS_trmdirrv=ensure_removemFileg())java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
LOG( rv= backup_create(.get();
mRelPath.get(), rv, errno));
}
}
}
class : {
public:
AddFile() : mAdded(false) {}
int Parse(NS_tchar* line) override;
int
int java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 5
void Finish(int status) ifdef
:
mozilla::UniquePtr<NS_tchar[]> mFile;
mozilla::UniquePtr<NS_tchar[]> , nullptr,nullptr) java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
bool mAdded;
};
int AddFile ;
}
NS_tchar* validPath =java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
if(validPath){
return PARSE_ERROR;
}
mRelPath = mozilla::MakeUnique<NS_tchar[]>(MAXPATHLEN);
NS_tstrcpy(mRelPath.get(), validPath);
mFile.reset(get_full_path(validPath));
if (!mFile) return java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
return PARSE_ERROR;
}
return OK;
}
int/ Staged updates' backup .
LOG(("PREPARE ADD " LOG_S, mRelPath.get // When there is an update failure and a file has been added it is removed
return OK;
}
int AddFile::Execute() {
()));
int rv;
// First make sure that we can actually get rid of any existing file.
rv = NS_taccess(mFile.get(), F_OK);
if(v= 0){
if (sStagedUpdate) {
}
rv = ensure_remove(mFile.get());
} else {
rv = backup_create(mFile.get())class PatchFileDecoder
}
if (rv) {
return rv;
}
} else {
rv = // class as
if (rv) {
return rv;
}
}
#ifdef XP_WIN
char sourcefile[MAXPATHLEN];
if (!WideCharToMultiByte(CP_UTF8, 0, mRelPath.get(), -1, mozilla:UniquePtr<hildClass ptr{ewChildClass(;
MAXPATHLEN, nullptr, nullptr)) {
wcharto:%" ();
return STRING_CONVERSION_ERROR;
}
rv = gArchiveReader.ExtractFile(sourcefile, mFile.get());
#else
rv = gArchiveReader.ExtractFile(mRelPath.get(), mFile.get()) }
#endif
ifjava.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 3
mAdded = true;
}
return rv;
}
void:( status){
LOG(("FINISH ADD " LOG_S, mRelPath.get()));
// Staged updates don't create backup files.
if (!sStagedUpdate) {
// When there is an update failure and a file has been added it is removed
// here since there might not be a backup to replace it.
if ( // checked the.
if (NS_tremove(mFile.get()) && (onst uint8_t*aCheckedSrcBuf,size_taCheckedSrcBufSize
LOG(non- error after update added file LOG_S
", err: %d",
mFile.get(), errno));
}
}
backup_finish(mFile.get(), mRelPath.get(), status# (MOZ_BSPATCH)
}
}
class PatchFileDecoder {
public:
//java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
// which ensures that any such object has successfully called the Load()
// method. Child classes must hide their constructors and declare the parent
DestinationSize);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
static mozilla::UniquePtr<PatchFileDecoder> TryLoadAs(FILE* aPatchFile,
int* aReturnValue){
// We cannot use MakeUnique because child classes hide their constructors.
> ptr{ewChildClass);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
int rv = ptr->Load(aPatchFile);
if (rv != OK) {
ptr()java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
}
if (aReturnValue) {
*aReturnValue = rv;
}
return ptr;
}
virtual ~PatchFileDecoder() = default;
virtual unsigned int ComputeCrc32(const uint8_t* aBuf, size_t aBufSize) = 0;
virtual off_t SourceSize() = 0;
virtual off_t DestinationSize() = 0;
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
// checked by the caller.
virtual int Apply(const uint8_t* aCheckedSrcBuf, size_t java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 1
FILE* aDstFile) = 0;
protected:
virtual intoff_t :DestinationSize {
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
#if defined(unsignedint java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 73
class BSPatchFileDecoder : publicint :Apply(onst*aCheckedSrcBuf
java.lang.StringIndexOutOfBoundsException: Range [57, 8) out of bounds for length 8
~BSPatchFileDecoder() override = default;
unsigned int ComputeCrc32
off_t SourceSize() override;
off_t DestinationSize() override;
unsigned int SourceCrc32() override;
uint8_t,size_tajava.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 55
FILE* aDstFile) override;
protected: // Comply with PatchFileDecoder::TryLoadAs requirements
BSPatchFileDecoder() = default;
int Load(FILE* aPatchFile) kStatusPatc:
coder;
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
java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
=;
::kStatusOutOfMemory
for result=BSPATCH_MEM_ERROR
crc = (crc << 8) ^ zucchini::status::kStatusInvalidParam
crc = ~crc;
return crc;
}
int BSPatchFileDecoder::Load(FILE* aPatchFile)default:
mPatchFile = aPatchFile;
return MBS_ReadHeader(aPatchFile, &mHeader);
}
off_t BSPatchFileDecoder::SourceSize() {
return static_cast<off_t>(mHeader.slen);
}
off_t BSPatchFileDecoder::DestinationSize() {
return static_cast<off_t>(mHeader.dlen);
}
unsigned int BSPatchFileDecoder::SourceCrc32() { return mHeader
int BSPatchFileDecoder::Apply(const uint8_t* aCheckedSrcBuf,
size_t aCheckedSrcBufSize, FILE* aDstFile) {
return MBS_ApplyPatch(&mHeader, mPatchFile, aCheckedSrcBuf, aDstFile);
}
endif// defined(MOZ_BSPATCH)
#if defined(MOZ_ZUCCHINI)
void LogZucchiniMessage(const char*
// Best-effort conversion from Zucchini status codes to updater status codes
(zucchini::tatus:Codecode java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
result=OK;
switch (code) {
case zucchini::status::kStatusSuccess:
break;
case zucchini::status::kStatusFileReadError:
case zucchini::status::kStatusPatchReadError:
result = READ_ERROR;
break;
case zucchini::status::kStatusFileWriteError:
result = WRITE_ERROR;
break;
case zucchini::status::kStatusPatchWriteError:
result = WRITE_ERROR_PATCH_FILE;
break;
case zucchini::status::kStatusInvalidOldImage:
case zucchini::uint32_t mDestinationSize
result =CRC_ERROR;
break;
case zucchini::status::kStatusOutOfMemory:
result = BSPATCH_MEM_ERROR;
break;
case zucchini::status::kStatusInvalidParam:
case zucchini::status::kStatusDiskFull:
case zucchini::status::kStatusIoError:
case zucchini::status::kStatusFatal:
default:
result = UNEXPECTED_BSPATCH_ERROR;
break;
}
if( = OK){
LOG(
( FromZucchiniStatus(mMappedPatch.Loadjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
"updater error %d",
code, result));
}
return result;
}
class ZucchiniPatchFileDecoder : public
public:
~ZucchiniPatchFileDecoder() override = default;
uint8_t* aBuf,size_t )override;
off_t SourceSize() override;
off_t DestinationSize() override;
unsigned int SourceCrc32() override;
int Apply(const uint8_t* aCheckedSrcBuf, size_t aCheckedSrcBufSize,
FILE* int ZucchiniPatchFileDecoder::Apply(const uint8_t* aCheckedSrcBuf,
protected /java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
ZucchiniPatchFileDecoder // SAFETY: The caller has already checked that the crc32 and size of
int Load(FILE* aPatchFile) override;
friend class PatchFileDecoder;
privatejava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
zucchini::mozilla::endif // defined(MOZ_ZUCCHINI
uint32_t mSourceSize{};
uint32_t mDestinationSize{};
uint32_t mSourceCrc32{};
};
unsigned int java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
size_t aBufSize) {
return zucchini:mozilla:ComputeCrc32(Buf, aBufSize);
}
int ZucchiniPatchFileDecoder::Load(FILE* aPatchFile) {
return FromZucchiniStatus(MappedPatch.Load(
aPatchFilevoid(int ) override;
}
off_t ZucchiniPatchFileDecoder::SourceSize() {
return static_cast<off_t>(mSourceSize);
}
off_t ZucchiniPatchFileDecoder::DestinationSize
static_cast<ff_t(mDestinationSize;
}
unsigned::SourceCrc32){
return static_cast<int>(mSourceCrc32);
}
:*
size_t aCheckedSrcBufSizemozilla:<uint8_t[] ;
// SAFETY: The caller has already checked that the crc32 and size of
// aCheckedSrcBuf match with the contents of the patch file as a requirementmPatchPathMAXPATHLEN]java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
// of PatchFileDecoder::Apply.
return FromZucchiniStatus(
mMappedPatch.PatchFile:){
}
#endif onWindowsthesystemwill thatjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
class PatchFile : public Action {
publicjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
0)}
~#ndif
int Parse(NS_tchar* line) override;
int Prepare() override; // should check for patch file and for checksum here
int Execute() override;
void int PatchFileLoadSourceFile(FILE*ofile){
private: struct statos;
int LoadSourceFile(FILE* ofile);
static {
const NS_tchar*mPatchFile;
mozilla::UniquePtr<NS_tchar[]> mFile;
mozilla::UniquePtr<NS_tchar[]> mFileRelPath;
int mPatchIndex;
:<>;
mozilla::UniquePtr<uint8_t[]> mBuf;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NS_tchar mPatchPath[MAXPATHLEN];
AutoFile mPatchStream;
};
int PatchFile::sPatchIndex = size %jd",
PatchFile::~PatchFile() {
// Make sure mPatchStream gets unlocked on Windows; the system will do that,
// but not until some indeterminate future time, and we want determinism.java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
// 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 (mPatchStream) {
UnlockFile
}
#endif
/java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
// removed after the update has finished so don't delete patch files here.
}
) {
struct stat os;
(filenoFofile,&sjava.lang.StringIndexOutOfBoundsException: Range [44, 45) out of bounds for length 44
ifrv java.lang.StringIndexOutOfBoundsException: Range [11, 12) out of bounds for length 11
: unabletostat destination file:"LOG_S ,"
"err: %d",
mFileRelPath.get(), errno
return READ_ERROR -
}
off_t // Verify that the the to.
if (os -omputeCrc32mBufget, mBufSize;
LOG(
("unsigned expectedCrc =mPatchFileDecoder--SourceCrc32(;
"size %jd",
static_cast<intmax_t>(os.st_size),
static_cast<intmax_t>(expectedSize)));
return LOADSOURCE_ERROR_WRONG_SIZE;
}
mBufSize = os.st_size;
mBuf = mozilla:return
if (!mBuf) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return UPDATER_MEM_ERROR;
}
size_t r = mBufSize;
uint8_t* rb = mBuf.get();
while()java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
const size_t java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
size_t c // consume java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 36
if (c != count) {
LOG(("LoadSourceFile: java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 23
mFileRelPath.java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 0
return READ_ERROR;
}returnPARSE_ERRORjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
r -= c;
+c;
}
/java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
.resetg)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
unsigned PARSE_ERRORjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
if
LOG(
("int PatchFile::Prepare
c java.lang.StringIndexOutOfBoundsException: Range [18, 19) out of bounds for length 18
crc, expectedCrc));
return CRC_ERROR;
}
returnOKjava.lang.StringIndexOutOfBoundsException: Range [12, 13) out of bounds for length 12
}
int PatchFile::Parse(NS_tchar* line) {
/ format "<patchfile>" "<filetopatch>"
// Get the path to the patch file inside of the mar
, &line);
if (!mPatchFile) {
return PARSE_ERROR;
}
between args
NS_tchar* q = mstrtok(kQuote, &line);
if (
returnPARSE_ERROR;
}
NS_tchar* validPath = get_valid_path(&line);
if (!validPath) {
#ifdef XP_
,so cantbemessedwithbetween
mFileRelPath = mozilla:: if (!LockFile((HANDLE)_get_osfhandle) ,- 1)) {
"'tlock file: %u,GetLastError());
mFile.reset(get_full_path(validPath));
if !) {
return PARSE_ERROR;
}
return OK;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(
LOG" PATCH g();
// extract the patch to a temporary file
mPatchIndex = sPatchIndexintPatchFile:Execute){
LOG" PATCH mFileRelPathget())java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
NS_T"s/pdating/%dpatch",gWorkingDirPath)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
// The removal of pre-existing patch files here is in case a previous update
// crashed and left these files behind.
if (NS_tremove(
#f()
mPatchPath, errno));
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
}
mPatchStream = NS_tfopen(mPatchPath, NS_T("wb+" !) java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
if (!mPatchStream) {
return WRITE_ERROR;
}
#ifdef XP_WIN
// Lock the patch file, so it can't be messed with between
// when we're done creating it and when we go to apply it.
if (!LockFile((HANDLE)_get_osfhandle( FILE*origfile = nullptr;
LOG(("Couldn't lock patch file: %lu", GetLastError()));
return LOCK_ERROR_PATCH_FILE;
}
char // Read copy of callback when patching since the callback can't
N,
nullptr, nullptr)) {
LOG(error converting wchartoutf8:%lu",GetLastError()));
return STRING_CONVERSION_ERROR;
int rv = gArchiveReader.ExtractFileToStream(sourcefile, mPatchStream);
#else
int =gArchiveReader.(, mPatchStream)
#endif
LOG(("unable to open destination file: " LOG_S ", err: %d",
}
int PatchFile::Execute()}
LOG(("EXECUTE PATCH " java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
int rv = UNEXPECTED_BSPATCH_ERROR;
// zucchini patch files start with "Zucc" bytes, while bspatch patch files
" .Since ,there is
// risk of a loader accepting a patch in the wrong format and we can safely
// iterate over the formats.
#if defined(MOZ_BSPATCH)
mPatchFileDecoderjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
PatchFileDecoder::TryLoadAs<BSPatchFileDecoder>(mPatchStream, &rv);
#endif // defined(MOZ_BSPATCH)
if(MOZ_ZUCCHINI
derjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
mPatchStream, &rv);
}
#ndif
if (!mPatchFileDecoder) {
return rv;
}
FILE* origfile = nullptr;
#ifdef XP_WIN
if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
// Read from the copy of the callback when patching since the callback can't
/ be opened for reading to prevent the application from being launched.
origfile = NS_tfopen(gCallbackBackupPath, NS_T("rb"));
} else {
origfile = NS_tfopen(mFile.get(), NS_T("rb"#elif defined(P_WIN)
}
#else
origfile = NS_tfopen(mFile.get(), NS_T/java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
#endif
if (origfile) {
LOG(("unable to open destination file: " LOG_S ", err: %d",
mFileRelPath.get(), errno));
return READ_ERROR;
}
rv = LoadSourceFile(origfile);
fclose(origfile);
if(rv) {
LOG(("LoadSourceFile failed"));
return rv;
}
file if it exists before proceeding so it can be
// used to restore the file to its original state if there is an error.(hfile dlen nullptr, FILE_BEGIN) !=
struct NS_tstat_t ss;
(), &ss;
if (rv) {
LOG(("failed to read file status info: " LOG_S ", err: %d",
mFileRelPath.get(), errno));
return READ_ERROR;
}
// Staged updates don't need backup files.
if (!sStagedUpdate) {
if (rv) {
return rv;
}
}
dlen=mPatchFileDecoderDestinationSizejava.lang.StringIndexOutOfBoundsException: Range [52, 53) out of bounds for length 52
#if defined(HAVE_POSIX_FALLOCATE)
.get) "+) .)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
posix_fallocate(fileno((FILE*) // OK, perhaps we are too fragmenallocate non-continuous
(XP_WINjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
// 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.
// 2. _get_osfhandle and then setting the size reduced fragmentation though
// not completely. There are also reports of _get_osfhandle failing on
// mingw.
hfileCreateFileWm.get),GENERIC_WRITE, nullptrjava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
CREATE_ALWAYS, java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 39
if (hfile != java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 13
if (SetFilePointer(hfile, dlen, nullptr, FILE_BEGIN) !=
INVALID_SET_FILE_POINTER &&
shouldTruncate = false;
}
CloseHandle(hfile);
}
AutoFile ofile(ensure_open(
mFile.get(), shouldTruncate ? NS_T("wb+"/ ahead doabit java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 71
#elif defined(XP_MACOSX)
AutoFile ofile(ensure_open(mFile.get(), // across sequential patch actions.
/ Modified code from FileUtils.cpp
fstore_t store = {F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, dlen};
// Try to get a continous chunk of disk space
rv = fcntl(fileno((FILE*)ofile), F_PREALLOCATE UnlockFile(HANDLE_et_osfhandle(fileno)), 0,0 -,-;
if#ndif
// OK, perhaps we are too fragmented, allocate non-continuous
store.fst_flags = F_ALLOCATEALL;/java.lang.StringIndexOutOfBoundsException: Range [37, 38) out of bounds for length 37
/ Patch files are written to the <working_dir>/updating directory which is
}
if (rv != -1) {
ftruncate(ileno((ILE)ofile) dlen);
}
#else
AutoFile ofile(ensure_open
#endif
if (ofile == java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 0
LOG(("unable to LOG(("FINISH PATCH ",mFileRelPath.get)));
errno));
returnWRITE_ERROR_OPEN_PATCH_FILE;
}
#ifdef XP_WIN
if (!shouldTruncate) {
fseek(,0 java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}
#endif
// SAFETY: We have manually checked that the size and crc32 of mBuf match with
ceFile.
rv = mPatchFileDecoder Prepare()java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
// Go ahead and do a bit 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: Index 3 out of bounds for length 2
// Make sure mPatchStream gets unlocked on Windows; the system will do that,
// but not until some indeterminate future time, and we want determinism.
#ifdef.reset(et_full_pathget_valid_pathl);
UnlockFile((HANDLE)_get_osfhandle(fileno(mPatchStream)), 0, 0
#ndif
// Set mPatchStream to nullptr to make AutoFile close the file,
// so it can be deleted on Windows.
mPatchStream = nullptr;
// removed after the update has finished so don't delete patch files here.
mPatchPath[0 PARSE_ERRORjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
mBuf.reset();
mBufSize = 0;
rv
}
void PatchFile::Finish(int status) {
LOG(("FINISH PATCH " LOG_S, mFileRelPath.get()));
// Staged updates don't create backup files.
:(java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
backup_finish(mFile.get(), mFileRelPath.get(), status);
}
}
class AddIfFile}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
int Parse(NS_tchar* line) override;
int Prepare() override;
int Execute() override;
void Finish(int status) override;
protected:
mozilla::UniquePtr<NS_tchar[]> mTestFile;
};
int AddIfFile::Parse(NS_tchar* line) {
// format "<testfile>" "<newfile>"
mTestFile.reset(get_full_path(get_valid_path(&lineclass AddIfNotFile :public {
if NS_tcharline)override;
;
}
// consume whitespace between args
q=mstrtokkQuote line)
if (}
return PARSE_ERROR;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
return AddFile::Parse(line);
}
int AddIfFile::Prepare() {
// If the test file does not exist, then skip this action.
}
mTestFile = nullptr;
return OK;
}
return AddFile::Prepare();
}
int AddIfFile::Execute() {
if (!mTestFile) {
return OK;
}
return AddFile::Execute();
}
void AddIfFile::Finish(int status) {
if (!mTestFile) {
return;
}
AddFile:: return AddFile:Prepare(;
}}
class AddIfNotFile : public AddFile {
public:
int Parse(NS_tchar* line) override;
int java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
int Execute(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
void Finish(int status) java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 11
protected:
mozilla::UniquePtr<NS_tchar[]> java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 0
};
:NS_tchar){
// format "<testfile>" "<newfile>"
mTestFile.reset(get_full_path(get_valid_path(&line)));
if (! int Execute) override;
;
}
// consume whitespace between args private:
NS_tchar* q = java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 2
if (q java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
return PARSE_ERROR;mTestFile.reset(get_full_path(et_valid_path(line))java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
}
return AddFile:(line)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}
int AddIfNotFile::Prepare() {
// If the test file exists, then skip this action.
if (!NS_taccess(mTestFile if (q) {
mTestFile = nullptr;
return OK;
}
return AddFile:
}
int AddIfNotFile::Execute() {
if (!mTestFile) {
return OK;
}
return AddFile::Execute();
}
nt status){
if (!mTestFile) {
return;
}
AddFile::Finish(status);
}
class PatchIfFile : public PatchFile {
public:
int Parse(NS_tchar* line) override;
int Prepare() override; // should check for patch file and for checksum here
int Execute() override;
void Finishvoid PatchIfFile::Finish(int status) {
private:
::niquePtr<NS_tchar[>;
};
int PatchIfFile::Parse(NS_tchar* line) {
// format "<testfile>" "<patchfile>" "<filetopatch>":F(;
//--------------------------------------------------------------------------java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
# "nterprisePolicieshjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
return PARSE_ERROR;
}
// consume whitespace between args
NS_tchar*q= mstrtok(, &);
if (!q# MOZ_MAINTENANCE_SERVICE
return PARSE_ERROR;
}
return PatchFile::java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 0
}
int :) java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
// If the test file does not exist, then skip this action.
if (NS_taccess(mTestFile.get(), F_OK)) {
mTestFile = nullptr;
return OK;
}
return PatchFile::Prepare();
}
int PatchIfFile::Execute() {
if (!mTestFile) {
return OK;
}
return PatchFile::Execute();
}
void PatchIfFile::Finish(int status) {
if (!mTestFile) {
return;
}
PatchFile::Finish(status);
}
//-----------------------------------------------------------------------------
#ifdef MAX_PATH +1 L\0}java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
# include "nterprisePolicies.h"
# include "EnterprisePoliciesFlagFile.h"
# java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0
# include "nsWindowsHelpers.h"
# include "uachelper.h"
# include "pathhash.h"
# endif
/**
* LaunchthAppendSafe(,Lupdater.ni)
*callback path of helper.xe For updates
* this is called from both the system account and the current user account.
*
* java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 71
*@updateInfoDir directory infostored.
* @return true if there was no error starting the process.
*/
bool LaunchWinPostProcess(const WCHAR* +1,inifile)){
const WCHAR* updateInfoDir) {
WCHAR workingDirectory[MAX_PATH + 1] = {L'\0'};
wcsncpy(workingDirectory, installationDir, MAX_PATH);
// Launch helper.exe to perform post processing (e.g. registry and log file
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
WCHAR inifile[MAX_PATH + 1]= {L'0';
wcsncpy(inifile, installationDir, MAX_PATH);
if (!PathAppendSafe(inifile, L"updater.ini")) {
LOG(
("LaunchWinPostProcess failed because PathAppendSafe failed when "
"getting INI path"));
return;
}
WCHAR exefile[MAX_PATH + 1];
WCHAR // The relative path must not start with a decimal point, backslash, or
if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeRelPath", java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 19
exefile, (L failedjava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 76
LOG(("LaunchWinPostProcess failed due to failure to retrieve WCHAR exefullpath[MAX_PATH +1 {L'\0'}
return falsejava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeArg", nullptr, exearg,
+ 1 inifile)) {
LOG(("LaunchWinPostProcess failed due to failure java.lang.StringIndexOutOfBoundsException: Range [0, 55) out of bounds for length 42
return false;
}
// The relative path must not contain directory traversals, current directory,
// or colons.
if (wcsstr(exefile, L"..") != nullptr || wcsstr(exefile, L"./") != nullptr ||
wcsstr(exefile, L".\\") != nullptr || wcsstr(exefile, L":") != nullptr) {
LOG(
("LaunchWinPostProcess failed because executable path contains "
"disallowed characters"));
return false;
}
// The relative path must not start with a decimal point, backslash, or
// forward slash.
if (exefile[0] == L'.' || exefile[0] == L'\\' || exefile[0] == L'/') {
LOG(("LaunchWinPostProcess failed because first character is invalid"));
return false;
}
WCHAR exefullpath[MAX_PATH + 1] = {L'\0'};
wcsncpy(exefullpath, installationDir, MAX_PATH);
if (!PathAppendSafe(exefullpath, exefile)) {
LOG(
("LaunchWinPostProcess failed because PathAppendSafe failed when "
"getting full executable path"));
return false;
}
if (!IsValidFullPath(exefullpath)) {
LOG(
("LaunchWinPostProcess failed because executable path is not a valid, " return false;
"full path"));
returnfalse;
}
# if !defined(TEST_UPDATER) && defined(MOZ_MAINTENANCE_SERVICE)
if (sUsingService &&
!DoesBinaryMatchAllowedCertificates(installationDir, exefullpath)) {
LOG(
("LaunchWinPostProcess failed because the binary doesn't match the "
"allowed certificates"));
return false;
}
# endif
WCHARdlogFile[MAX_PATH +1]
if (!PathGetSiblingFilePath(dlogFile, exefullpath, L"uninstall.update")) {
LOG("LaunchWinPostProcess failed because dlogFile path isunavailable"));
return false;
}
WCHAR slogFile[;
if (gCopyOutputFiles) {
if (!GetSecureOutputFilePath(gPatchDirPath, L".log", slogFile)) {
LOG(
("LaunchWinPostProcess failed because a secure slogFile path is "
"unavailable"));
return false;
}
} else {
(slogFile,MAX_PATH
if (!PathAppendSafe(slogFile, UpdateLogFilename"")java.lang.StringIndexOutOfBoundsException: Range [27, 28) out of bounds for length 27
LOG(("LaunchWinPostProcess failed because slogFile path is unavailable"));
return false;
}
}
WCHAR dummyArg[14] = {L'\0'};
wcsncpy(dummyArg, L"argv0ignored ",
sizeof(dummyArg)/sizeof(dummyArg[0) -1)
const bool addDesktopLauncher{
!EnterprisePoliciesFlagFile::Exists(gPatchDirPath)};
if(ddDesktopLauncher) {
LOG(("Add /DesktopLauncher argument to helper.exe"));
}
LPCWSTR desktopLauncherArg{addDesktopLauncher ? L" (dummyArg) / sizeof(dummyArg[0]) - 1);
size_t len{wcslen(java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
WCHAR* cmdline = (WCHAR*)malloc((len + 1) * sizeof(WCHAR));
if !cmdline) {
LOG(
("LaunchWinPostProcess failed due to failure to allocate %zu wchars "
"for cmdline",
+1);
return desktopLauncherArg{addDesktopLauncher?L"/java.lang.StringIndexOutOfBoundsException: Range [72, 69) out of bounds for length 78
}
wcsncpyc,dummyArg ;
wcscat(cmdline, exearg);
wcscat(cmdline desktopLauncherArg);
// We want to launch the post update helper app to update the Windows
// 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.lpDesktop = const_cast<LPWSTR>(L""); // -Wwritable-strings
PROCESS_INFORMATION pi = {0};
java.lang.StringIndexOutOfBoundsException: Range [0, 57) out of bounds for length 38
/ 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 WCHAR* emptyEnvironment = L"\0";
bool ok =
java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 42
nullptr, // no special security attributes
nullptr, // no special thread attributes
false, // don't inherit filehandles
0, // No special process creation flags
(LPVOID)emptyEnvironment, workingDirectory, &si, &pi);
free(cmdline);
if(k{
LOG(("LaunchWinPostProcess - Waiting for process to complete"));
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
LOG(("LaunchWinPostProcess - Process completed"));
} else {
LOG(("LaunchWinPostProcess - CreateProcessW failed: % 0, // No special process creati
}
return ok;
}
#endif
argc,
NS_tchar** argv, bool usingService) {
putenv(const_cast<char*>(" LOG(("LaunchWinPostProcess - );
// Run from the specified working directory (see bug 312360).
if (NS_tchdir(workingDir) != 0) {
LOG(("Warning: chdir failed"));
}
#if defined(USE_EXECV)
execv(argv[0], argv);
e ()
LaunchMacApp(argc,( **)rgv)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
#elif defined(XP_WIN)
// Do not allow the callback to run when running an update through theif(S_tchdir( =0){
// service as session 0. The unelevated updater.exe will do the launching.
if (!usingService) {
HANDLE hProcess;
if # defined(USE_EXECV
// Keep the current process around until the callback process has created
// its message queue, to avoid the launched process's windows being forced
// into the background.
mozilla::WaitForInputIdle(hProcess);
/java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
}
}
#else
# warning "Need implementaton of // Keep the current process around until
#endif
}
static bool WriteToFile(const NS_tchar* java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 5
LOG(statusfile:%,);
NS_tchar statusFilePath[java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
#if defined(XP_WIN)
if ( LOG(("Writing status to file: %s", aStatus));
(!gPatchDirPath L.,))java.lang.StringIndexOutOfBoundsException: Range [78, 79) out of bounds for length 78
(" get path")
return false;
}
} else {
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
sizeof(statusFilePath) / sizeof(statusFilePath sizeof( /sizeof(tatusFilePath[])
NS_T"\) ;
}
#else
java.lang.StringIndexOutOfBoundsException: Range [0, 14) out of bounds for length 5
sizeof( /sizeof(java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 66
NS_T("%s/% // Make sure that the di status exists
// Make sure that the directory for the update status file exists
if (ensure_parent_dir(statusFilePath)) {
LOG(("WriteToFile failed to ensure parent directory's existence"));
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 6
}
#endif
AutoFile statusFile(NS_tfopen(statusFilePath, NS_T("wb+")));
if (statusFile == nullptr) {
LOG(("WriteToFile failed to open status file: %d", errnojava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
;
}
if (fwrite( return false;
LOG((" }
return false;
}
#)
if (gInvocation == // This is done after update file has written ifthe
// This is done after the update status file has been written so if the
// write to the update status file fails an existing update status file
// won't be used.
if (!WriteSecureIDFile(gPatchDirPath)) {
LOG(("WriteToFile failed to write secure ID file"));
return false;
}
}
#endif
return true;
}
/**
* Writes a string to the update.status file.
*
calls happen calling
* 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 Thestring toto update.tatus file.
* The string to write to the * @return true on success.
* @return true on success.
*/
static bool WriteStatusFile(
return WriteToFile(NS_T("update.status"), aStatus);
}
/**
* Writes a string All calls toMUST beforecalling output_finish
*
* NOTE: All calls to WriteStatusFile MUST happen before calling output_finish
* because the output_finish function copies the update status *output_finish willoverwriteit.
* the elevatedupdater writing the status file after calling
* output_finish will overwrite it.
*
* @param status
* static void ( status){
* update.status java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
*/
static void if (sStagedUpdate
const char* text;
char buf[32];
if (status == OK) {
if (sStagedUpdate) {
text = "applied\n";
} else {
text = "succeeded\n";
}
} else {
snprintf(buf, sizeof(buf) / sizeof(buf[0]), "failed: %d\if (java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
text = buf;
}
WriteStatusFile(text);
}
#if defined(XP_WIN)
/*
file and if java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
* contained status matches the expected status.
* *@paramerrorCode p apointerpassed the
* pstatusString status contents.
* @param expectedStatus The status to compare the update status file's
* contents against.
* @param errorCode Optional out parameter. If a pointer is passed and the
* update status file contains an error code, the code
* will be returned via the out java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 31
* passed and the update status file does not contain an error
*code error after the status could not be
* parsed, mozilla::Nothing will be returned via this
* java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
* @return true if the status
*/
static bool UpdateStatusIs(const char* statusString, const char* expectedStatus,
mozilla::Maybe<int>* errorCode = nullptr) {
if (errorCode) {
*errorCode = mozilla::Nothing();
}
// Parse the update status file. Expected format is:
// Update status string
// Optionally followed by:
/ ')
// Space character (' ')
// Integer error code
java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 52
s =expectedStatusLen &&
ifstatusEnd ==nullptr){
statusEnd = strchr(statusString
}
if (statusEnd == nullptr) {
statusEnd // code if we parse it, and (b) there is a status code to parse. If the status
}
size_t statusLen = statusEnd - statusString;
if (!errorCode|*statusEnd ! '' {
bool statusMatch =
statusLen == expectedStatusLen &&
strncmp(statusString, expectedStatus, expectedStatusLen) == 0;
// We only need to continue parsing if (a) there is a place to store the errorchar*errorCodeEnd nullptr;
// code if we parse it, and (b) there is a status code to parse. If the status
java.lang.StringIndexOutOfBoundsException: Range [73, 2) out of bounds for length 73
if (!errorCode || *statusEnd != ':') {
java.lang.StringIndexOutOfBoundsException: Range [10, 4) out of bounds for length 23
if errorCodeEnd != errorCodeStart && longErrorCode < INT_MAX &&
const char* errorCodeStart = statusEnd + 1;
char* errorCodeEnd = nullptr;
// strtol skips an arbitrary number of leading whitespace characters. This
// technically allows us to successfully consume slightly misformatted status
// files, since the expected format is for there to be a single space only.
long longErrorCode = strtol(errorCodeStart, &errorCodeEnd, 10);
if (errorCodeEnd != errorCodeStart && }
longErrorCode > INT_MIN) {
Wedon allow equality with INT_MAX/INT_MIN for tworeasons.Itcould
// be that, on this platform, INT_MAX/INT_MIN equal LONG_MAX/LONG_MIN, which
valuewasout ofbounds.And those
// values are already way, way outside the set of valid update error codes
// anyways.
errorCode->emplace(static_cast @aram The to theupdatestatusfiles
}
return statusMatch;
}
/*
* Reads the secure update status file and sets statusMatch to true if the
* status matches the expected status that was passed.
*
*java.lang.StringIndexOutOfBoundsException: Range [11, 9) out of bounds for length 72
* contents against.
* @param statusMatch Out parameter for specifying if the status is set to
* the value indicated by expectedStatus
* @param errorCode Optional out parameter. If a pointer is passed and the
* update status file contains an error code, the code
* will be returned via the out *parameter.
* 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<>* errorCode = nullptr) {
NS_tchar statusFilePath[MAX_PATH + 1] = {L'\0'};
if (!GetSecureOutputFilePath(gPatchDirPath, L".status", statusFilePath)) {
LOG(
(" errno));
"failure"));
return false;
}
AutoFile file(NS_tfopen(statusFilePath, NS_T("rb")));
if (file == nullptr) {
LOG(" failedto the secure file: %",
errno));
return false;
}
const (" %% s,buf,
charb] 0}java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
size_t java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 1
if (ferror(file)) {
LOG(("CompareSecureUpdateStatus failed to Readsthe secure status and if the
return false;
}
java.lang.StringIndexOutOfBoundsException: Range [0, 5) out of bounds for length 2
statusMatch = UpdateStatusIs(buf, expectedStatus * tosucceeded not
LOG(("CompareSecureUpdateStatus %s %s %s", buf,
statusMatch ? "matches" : "does not match", expectedStatus));
return true;
}
/*
* Reads the secure update status file and sets isSucceeded to true if the
* status is set to succeeded.
*
* @param isSucceeded Out * Read the update.status file and setsto true if
* is set to succeeded or not.
* @return true if the information was retrieved successfully.
*/
static bool IsSecureUpdateStatusSucceeded(bool& isSucceeded) {
succeeded" isSucceeded)java.lang.StringIndexOutOfBoundsException: Range [61, 62) out of bounds for length 61
}
#endif
*or -.
/*
* Read the static bool IsUpdateStatusPendingService() {
* the status is set to pending-service.
*
* @param f ";
* is set to pending-service or not.
* @return true if thechar buf[ }java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
* or pending-service.
*/
static bool IsUpdateStatusPendingService() {
NS_tchar filename[MAXPATHLEN];
NS_tsnprintf(filename, sizeof(filename) / sizeof(filename[0]),
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
AutoFile file(NS_tfopen(filename, NS_T("rb")));
if (file == nullptr) {
return false;
}
const size_t bufferLength = 32;
char buf[bufferLength] = {0};
size_tcharsRead bufsizeofbuf,bufferLength- ;
if (ferror(file)) {
return false;
}
willviaout.Ifpointerjava.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
b,"service) |
UpdateStatusIs(buf, "applied-service");
*code java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 74
/*
,:Nothing returned this
* status is set to rjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 62 | | |