big bug fix for ipsw-creation without -memory; now uses an error message to yell at you for giving it bad tars to merge rather than segfaulting; decreased stack use to accomodate Window's 1 MB stack limit

This commit is contained in:
planetbeing 2008-07-31 22:47:03 +00:00
Родитель 7fbfbddf12
Коммит e606deef03
3 изменённых файлов: 13 добавлений и 5 удалений

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

@ -400,6 +400,12 @@ int main(int argc, char* argv[]) {
for(; mergePaths < argc; mergePaths++) { for(; mergePaths < argc; mergePaths++) {
XLOG(0, "merging %s\n", argv[mergePaths]); XLOG(0, "merging %s\n", argv[mergePaths]);
AbstractFile* tarFile = createAbstractFileFromFile(fopen(argv[mergePaths], "rb")); AbstractFile* tarFile = createAbstractFileFromFile(fopen(argv[mergePaths], "rb"));
if(tarFile == NULL) {
XLOG(1, "cannot find %s, make sure your slashes are in the right direction\n", argv[mergePaths]);
releaseOutput(&outputState);
closeRoot(buffer);
exit(0);
}
hfs_untar(rootVolume, tarFile); hfs_untar(rootVolume, tarFile);
tarFile->close(tarFile); tarFile->close(tarFile);
} }

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

@ -173,20 +173,20 @@ void writeOutput(OutputState** state, char* ipsw) {
if(curFile->tmpFileName == NULL) { if(curFile->tmpFileName == NULL) {
ASSERT(zipWriteInFileInZip(zip, curFile->buffer, curFile->bufferSize) == 0, "error writing to zip"); ASSERT(zipWriteInFileInZip(zip, curFile->buffer, curFile->bufferSize) == 0, "error writing to zip");
} else { } else {
FILE* tmpFile = fopen(curFile->tmpFileName, "wb"); AbstractFile* tmpFile = createAbstractFileFromFile(fopen(curFile->tmpFileName, "rb"));
char* buffer = malloc(DEFAULT_BUFFER_SIZE); char* buffer = malloc(DEFAULT_BUFFER_SIZE);
size_t left = curFile->bufferSize; size_t left = tmpFile->getLength(tmpFile);
while(left > 0) { while(left > 0) {
size_t toRead; size_t toRead;
if(left > DEFAULT_BUFFER_SIZE) if(left > DEFAULT_BUFFER_SIZE)
toRead = DEFAULT_BUFFER_SIZE; toRead = DEFAULT_BUFFER_SIZE;
else else
toRead = left; toRead = left;
fread(buffer, toRead, 1, tmpFile); ASSERT(tmpFile->read(tmpFile, buffer, toRead) == toRead, "error reading data");
ASSERT(zipWriteInFileInZip(zip, buffer, toRead) == 0, "error writing to zip"); ASSERT(zipWriteInFileInZip(zip, buffer, toRead) == 0, "error writing to zip");
left -= toRead; left -= toRead;
} }
fclose(tmpFile); tmpFile->close(tmpFile);
free(buffer); free(buffer);
} }
} else { } else {

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

@ -25,7 +25,7 @@ Dictionary* parseIPSW2(const char* inputIPSW, const char* bundleRoot, char** bun
FILE* inputIPSWFile; FILE* inputIPSWFile;
SHA_CTX sha1_ctx; SHA_CTX sha1_ctx;
char buffer[BUFFERSIZE]; char* buffer;
int read; int read;
unsigned char hash[20]; unsigned char hash[20];
@ -44,12 +44,14 @@ Dictionary* parseIPSW2(const char* inputIPSW, const char* bundleRoot, char** bun
XLOG(0, "Hashing IPSW...\n"); XLOG(0, "Hashing IPSW...\n");
buffer = malloc(BUFFERSIZE);
SHA1_Init(&sha1_ctx); SHA1_Init(&sha1_ctx);
while(!feof(inputIPSWFile)) { while(!feof(inputIPSWFile)) {
read = fread(buffer, 1, BUFFERSIZE, inputIPSWFile); read = fread(buffer, 1, BUFFERSIZE, inputIPSWFile);
SHA1_Update(&sha1_ctx, buffer, read); SHA1_Update(&sha1_ctx, buffer, read);
} }
SHA1_Final(hash, &sha1_ctx); SHA1_Final(hash, &sha1_ctx);
free(buffer);
fclose(inputIPSWFile); fclose(inputIPSWFile);