Skip to content
Browse files

fixed a few bugs, should be much faster, but doesn't pack the filesys…

…tem and plists into the ipsw
  • Loading branch information...
1 parent c1f4e77 commit 7609d82c0f3dc15496bb01ec3c87275ed0ab7457 @posixninja committed May 7, 2010
Showing with 32 additions and 52 deletions.
  1. +32 −52 fwstitcher/fwstitcher.c
View
84 fwstitcher/fwstitcher.c
@@ -264,64 +264,44 @@ void createTssFirmware(TssResponse* response, const char* input, char* output) {
}
// Extract entire IPSW
- OutputState* in_state = loadZip(input);
- OutputState* out_state = malloc(sizeof(OutputState));
- while (in_state != NULL) {
- // Search through all entries in our response
- Dictionary* entry = (Dictionary*) root->values;
- while (entry != NULL) {
-
- // Make sure this entry is a dictionary
- if (entry->dValue.type != DictionaryType) {
- entry = (Dictionary*) entry->dValue.next;
- continue;
- }
-
- // And that we have the proper values
- StringValue* path = (StringValue*) getValueByKey(entry, "Path");
- StringValue* blob = (StringValue*) getValueByKey(entry, "Blob");
- if (path == NULL || blob == NULL) {
- fprintf(stderr, "Unable to find the proper values in this entry\n");
- entry = (Dictionary*) entry->dValue.next;
- continue;
- }
+ OutputState* in_state = NULL;
+ Dictionary* entry = (Dictionary*) root->values;
+ while (entry != NULL) {
+ // Make sure this entry is a dictionary
+ if (entry->dValue.type != DictionaryType) {
+ entry = (Dictionary*) entry->dValue.next;
+ continue;
+ }
- // Is this entry match the current one in state
- printf("Replacing SHSH on %s\n", entry->dValue.key);
-
- char* data = NULL;
- size_t data_size = 0;
- delchar(blob->value, '\t');
- delchar(blob->value, '\n');
- base64_decode_alloc(blob->value, strlen(blob->value), &data, &data_size);
-
- AbstractFile* signature = createAbstractFileFromMemory((void**) &data, data_size);
- AbstractFile* file = getFileFromOutputState(&in_state, path->value);
- replaceImg3Signature(file, signature);
- char* in_data = malloc(file->getLength(file));
- file->read(file, in_data, file->getLength(file));
- size_t in_len = file->getLength(file);
- addToOutput(&out_state, entry->dValue.key, in_data, in_len);
- signature->close(signature);
- file->close(file);
-
- char* tmp = createTempFile();
- AbstractFile* store = createAbstractFileFromFile(fopen(tmp, "wb"));
- store->write(store, in_data, file->getLength(file));
- store->close(store);
-
- //addToOutput2(&out_state, path->value, file->data, file->getLength(file), tmp);
- //removeFileFromOutputState(&in_state, path->value);
- free(data);
- free(tmp);
+ // And that we have the proper values
+ StringValue* path = (StringValue*) getValueByKey(entry, "Path");
+ StringValue* blob = (StringValue*) getValueByKey(entry, "Blob");
+ if (path == NULL || blob == NULL) {
+ fprintf(stderr, "Unable to find the proper values in this entry\n");
entry = (Dictionary*) entry->dValue.next;
+ continue;
}
- in_state = in_state->next;
+ // Is this entry match the current one in state
+ printf("Replacing SHSH on %s\n", entry->dValue.key);
+
+ char* data = NULL;
+ size_t data_size = 0;
+ delchar(blob->value, '\t');
+ delchar(blob->value, '\n');
+ base64_decode_alloc(blob->value, strlen(blob->value), &data, &data_size);
+ AbstractFile* signature = createAbstractFileFromMemory((void**) &data, data_size);
+
+ loadZipFile(input, &in_state, path->value);
+ AbstractFile* file = openAbstractFile(getFileFromOutputState(&in_state, path->value));
+ replaceImg3Signature(file, signature);
+ file->close(file);
+ entry = (Dictionary*) entry->dValue.next;
}
-
+
+ writeOutput(&in_state, output);
+ releaseOutput(&in_state);
releaseDictionary(root);
- writeOutput(&out_state, output);
}
void replaceImg3Signature(AbstractFile* file, AbstractFile* signature) {

0 comments on commit 7609d82

Please sign in to comment.
Something went wrong with that request. Please try again.