Skip to content

Commit

Permalink
conf: Fix false plist read/write errors caused by using new libplist API
Browse files Browse the repository at this point in the history
Thanks to @intelfx for spotting this.
  • Loading branch information
nikias committed May 5, 2023
1 parent 049877e commit 5a23434
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static int internal_set_value(const char *config_file, const char *key, plist_t
usbmuxd_log(LL_DEBUG, "Setting key %s in config file %s", key, config_file);
}

int res = plist_write_to_file(config, config_file, PLIST_FORMAT_XML, 0);
int res = (plist_write_to_file(config, config_file, PLIST_FORMAT_XML, 0) == PLIST_ERR_SUCCESS)

plist_free(config);

Expand All @@ -277,7 +277,7 @@ static int config_set_value(const char *key, plist_t value)

int result = internal_set_value(config_file, key, value);
if (!result) {
usbmuxd_log(LL_ERROR, "ERROR: Failed to write to '%s': %s", config_file, strerror(errno));
usbmuxd_log(LL_ERROR, "ERROR: Failed to write to '%s'", config_file);
}

free(config_file);
Expand All @@ -291,7 +291,7 @@ static int internal_get_value(const char* config_file, const char *key, plist_t

/* now parse file to get the SystemBUID */
plist_t config = NULL;
if (plist_read_from_file(config_file, &config, NULL)) {
if (plist_read_from_file(config_file, &config, NULL) == PLIST_ERR_SUCCESS) {
usbmuxd_log(LL_DEBUG, "Reading key %s from config file %s", key, config_file);
plist_t n = plist_dict_get_item(config, key);
if (n) {
Expand Down

0 comments on commit 5a23434

Please sign in to comment.