Bug 1595470 - Prevent EnsureCorrectPermissions from making faulty assumptions about childBuffer r=rstrong

Differential Revision: https://phabricator.services.mozilla.com/D52604

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kirk Steuber 2019-11-13 02:00:18 +00:00
Родитель d34efa221b
Коммит 99edf9e247
1 изменённых файлов: 7 добавлений и 6 удалений

Просмотреть файл

@ -1510,12 +1510,6 @@ static HRESULT EnsureCorrectPermissions(SimpleAutoString& path,
return returnValue;
}
SimpleAutoString childBuffer;
if (!childBuffer.AllocEmpty(MAX_PATH)) {
// Fatal error. We need a buffer to put the path in.
return FAILED(returnValue) ? returnValue : E_OUTOFMEMORY;
}
// Recurse into the directory.
DIR directoryHandle(path.String());
errno = 0;
@ -1526,6 +1520,13 @@ static HRESULT EnsureCorrectPermissions(SimpleAutoString& path,
continue;
}
SimpleAutoString childBuffer;
if (!childBuffer.AllocEmpty(MAX_PATH)) {
// Just return on this failure rather than continuing. It is unlikely that
// this error will go away for the next path we try.
return FAILED(returnValue) ? returnValue : E_OUTOFMEMORY;
}
childBuffer.AssignSprintf(MAX_PATH + 1, L"%s\\%s", path.String(),
entry->d_name);
if (childBuffer.Length() == 0) {