Skip to content

Commit

Permalink
Update to v1.0.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkMatterCore committed Apr 23, 2019
1 parent d22add4 commit fd4b7e9
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 37 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ include $(DEVKITPRO)/libnx/switch_rules

VERSION_MAJOR := 1
VERSION_MINOR := 0
VERSION_MICRO := 6
VERSION_MICRO := 7

APP_TITLE := gcdumptool
APP_AUTHOR := MCMrARM, DarkMatterCore
APP_VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}
APP_VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}

TARGET := gcdumptool
BUILD := build
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Thanks to
Changelog
--------------

**v1.0.7:**

* Fixed a segmentation fault when trying to free an invalid XML node data pointer when a Scene release from NSWReleases.xml with a matching Title ID misses data related to that node.
* Added a message suggesting the user to restart the application after a successful update.

**v1.0.6:**

* Updated application codebase in order to make it compatible with the latest devkitA64 and libnx releases.
Expand Down
95 changes: 61 additions & 34 deletions source/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const char *nswReleasesChildrenImageSize = "imagesize";
const char *nswReleasesChildrenTitleID = "titleid";
const char *nswReleasesChildrenImgCrc = "imgcrc";
const char *nswReleasesChildrenReleaseName = "releasename";
const char *nswReleasesChildrenCard = "card";

const char *githubReleasesApiUrl = "https://api.github.com/repos/DarkMatterCore/gcdumptool/releases/latest";
const char *gcDumpToolTmpPath = "sdmc:/switch/gcdumptool.nro.tmp";
Expand Down Expand Up @@ -426,75 +425,98 @@ void removeDirectory(const char *path)

bool parseNSWDBRelease(xmlDocPtr doc, xmlNodePtr cur, u32 crc)
{
if (!doc || !cur) return false;

xmlChar *key;
xmlNodePtr node = cur;

u8 imageSize = (u8)(gameCardSize / GAMECARD_SIZE_1GiB);
u8 card = (hfs0_partition_cnt == GAMECARD_TYPE1_PARTITION_CNT ? 1 : 2);

u8 xmlImageSize = 0;
u64 xmlTitleID = 0;
u32 xmlCrc = 0;
u8 xmlCard = 0;
char xmlReleaseName[256] = {'\0'};

bool found = false;
char strbuf[512] = {'\0'};

while (node != NULL)
while(node != NULL)
{
if ((!xmlStrcmp(node->name, (const xmlChar *)nswReleasesChildrenImageSize)))
{
key = xmlNodeListGetString(doc, node->xmlChildrenNode, 1);

xmlImageSize = (u8)atoi((const char*)key);

xmlFree(key);
if (key)
{
xmlImageSize = (u8)atoi((const char*)key);
xmlFree(key);
}
} else
if ((!xmlStrcmp(node->name, (const xmlChar *)nswReleasesChildrenTitleID)))
{
key = xmlNodeListGetString(doc, node->xmlChildrenNode, 1);

xmlTitleID = strtoull((const char*)key, NULL, 16);

xmlFree(key);
if (key)
{
xmlTitleID = strtoull((const char*)key, NULL, 16);
xmlFree(key);
}
} else
if ((!xmlStrcmp(node->name, (const xmlChar *)nswReleasesChildrenImgCrc)))
{
key = xmlNodeListGetString(doc, node->xmlChildrenNode, 1);

xmlCrc = strtoul((const char*)key, NULL, 16);

xmlFree(key);
if (key)
{
xmlCrc = strtoul((const char*)key, NULL, 16);
xmlFree(key);
}
}
if ((!xmlStrcmp(node->name, (const xmlChar *)nswReleasesChildrenReleaseName)))
{
key = xmlNodeListGetString(doc, node->xmlChildrenNode, 1);

snprintf(xmlReleaseName, sizeof(xmlReleaseName) / sizeof(xmlReleaseName[0]), "%s", (char*)key);

xmlFree(key);
} else
if ((!xmlStrcmp(node->name, (const xmlChar *)nswReleasesChildrenCard)))
{
key = xmlNodeListGetString(doc, node->xmlChildrenNode, 1);

xmlCard = (u8)atoi((const char*)key);

xmlFree(key);
if (key)
{
snprintf(xmlReleaseName, sizeof(xmlReleaseName) / sizeof(xmlReleaseName[0]), "%s", (char*)key);
xmlFree(key);
}
}

node = node->next;
}

//snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Cartridge Image Size: %u\nCartridge Title ID: %016lX\nCartridge Image CRC32: %08X\nCartridge Type: %u\n\nXML Image Size: %u\nXML Title ID: %016lX\nXML Image CRC32: %08X\nXML Release Name: %s\nXML Card Type: %u", imageSize, gameCardTitleID, crc, card, xmlImageSize, xmlTitleID, xmlCrc, xmlReleaseName, xmlCard);
//uiDrawString(strbuf, 0, 0, 255, 255, 255);
/*if (xmlImageSize && xmlTitleID && strlen(xmlReleaseName))
{
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Cartridge Image Size: %u.", imageSize);
uiDrawString(strbuf, 0, breaks * font_height, 255, 255, 255);
breaks++;
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Cartridge Title ID: %016lX.", gameCardTitleID);
uiDrawString(strbuf, 0, breaks * font_height, 255, 255, 255);
breaks++;
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Cartridge Image CRC32: %08X.", crc);
uiDrawString(strbuf, 0, breaks * font_height, 255, 255, 255);
breaks += 2;
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "XML Image Size: %u.", xmlImageSize);
uiDrawString(strbuf, 0, breaks * font_height, 255, 255, 255);
breaks++;
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "XML Title ID: %016lX.", xmlTitleID);
uiDrawString(strbuf, 0, breaks * font_height, 255, 255, 255);
breaks++;
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "XML Image CRC32: %08X.", xmlCrc);
uiDrawString(strbuf, 0, breaks * font_height, 255, 255, 255);
breaks++;
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "XML Release Name: %s.", xmlReleaseName);
uiDrawString(strbuf, 0, breaks * font_height, 255, 255, 255);
breaks += 2;
}*/

if (xmlImageSize == imageSize && xmlTitleID == gameCardTitleID && xmlCrc == crc && xmlCard == card)
if (xmlImageSize == imageSize && xmlTitleID == gameCardTitleID && xmlCrc == crc)
{
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Found matching Scene release: \"%s\" (CRC32: %08X). This is a good dump!", xmlReleaseName, xmlCrc);
uiDrawString(strbuf, 0, breaks * font_height, 0, 255, 0);

found = true;
} else {
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Dump doesn't match Scene release: \"%s\"! (CRC32: %08X)", xmlReleaseName, xmlCrc);
Expand Down Expand Up @@ -545,7 +567,7 @@ void gameCardDumpNSWDBCheck(u32 crc)
uiRefreshDisplay();

u32 i;
for (i = 0; i < nodeSet->nodesetval->nodeNr; i++)
for(i = 0; i < nodeSet->nodesetval->nodeNr; i++)
{
xmlNodePtr node = nodeSet->nodesetval->nodeTab[i]->xmlChildrenNode;

Expand Down Expand Up @@ -943,9 +965,14 @@ void updateApplication()

if (res == CURLE_OK && http_code >= 200 && http_code <= 299 && size > 0)
{
success = true;

snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Successfully downloaded %.0lf bytes!", size);
uiDrawString(strbuf, 0, breaks * font_height, 0, 255, 0);
success = true;
breaks++;

snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Please restart the application to reflect the changes.", size);
uiDrawString(strbuf, 0, breaks * font_height, 0, 255, 0);
} else {
snprintf(strbuf, sizeof(strbuf) / sizeof(strbuf[0]), "Error: failed to request latest update binary! HTTP status code: %ld", http_code);
uiDrawString(strbuf, 0, breaks * font_height, 255, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion source/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define MiB (1024.0 * KiB)
#define GiB (1024.0 * MiB)

#define APP_VERSION "1.0.6"
#define APP_VERSION "1.0.7"

#define NAME_BUF_LEN 4096

Expand Down

0 comments on commit fd4b7e9

Please sign in to comment.