From 35b0543ec2a54250be011a9ffdd1d70f2c1ced5c Mon Sep 17 00:00:00 2001 From: BALATON Zoltan Date: Wed, 23 Sep 2015 02:11:54 +0200 Subject: idevicebackup: fix some timestamps that are relative to the Mac epoch instead of Unix one --- common/utils.h | 2 ++ tools/idevicebackup.c | 4 ++-- tools/idevicebackup2.c | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/common/utils.h b/common/utils.h index 90cfa4a..8426bc0 100644 --- a/common/utils.h +++ b/common/utils.h @@ -33,6 +33,8 @@ #include #include +#define MAC_EPOCH 978307200 + #ifndef HAVE_STPCPY char *stpcpy(char *s1, const char *s2); #endif diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 2619cc9..7e825de 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c @@ -251,7 +251,7 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid) if (value_node) plist_dict_set_item(ret, "IMEI", plist_copy(value_node)); - plist_dict_set_item(ret, "Last Backup Date", plist_new_date(time(NULL), 0)); + plist_dict_set_item(ret, "Last Backup Date", plist_new_date(time(NULL) - MAC_EPOCH, 0)); value_node = plist_dict_get_item(root_node, "ProductType"); plist_dict_set_item(ret, "Product Type", plist_copy(value_node)); @@ -288,7 +288,7 @@ static void mobilebackup_info_update_last_backup_date(plist_t info_plist) return; node = plist_dict_get_item(info_plist, "Last Backup Date"); - plist_set_date_val(node, time(NULL), 0); + plist_set_date_val(node, time(NULL) - MAC_EPOCH, 0); node = NULL; } diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 934cf39..be5a1a0 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c @@ -146,10 +146,10 @@ static void mobilebackup_afc_get_file_contents(afc_client_t afc, const char *fil uint32_t bread = 0; afc_file_read(afc, f, buf+done, 65536, &bread); if (bread > 0) { + done += bread; } else { break; } - done += bread; } if (done == fsize) { *size = fsize; @@ -223,7 +223,7 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid, lockdownd_c if (value_node) plist_dict_set_item(ret, "IMEI", plist_copy(value_node)); - plist_dict_set_item(ret, "Last Backup Date", plist_new_date(time(NULL), 0)); + plist_dict_set_item(ret, "Last Backup Date", plist_new_date(time(NULL) - MAC_EPOCH, 0)); value_node = plist_dict_get_item(root_node, "PhoneNumber"); if (value_node && (plist_get_node_type(value_node) == PLIST_STRING)) { @@ -914,7 +914,8 @@ static void mb2_handle_list_directory(mobilebackup2_client_t mobilebackup2, plis } plist_dict_set_item(fdict, "DLFileType", plist_new_string(ftype)); plist_dict_set_item(fdict, "DLFileSize", plist_new_uint(st.st_size)); - plist_dict_set_item(fdict, "DLFileModificationDate", plist_new_date(st.st_mtime, 0)); + plist_dict_set_item(fdict, "DLFileModificationDate", + plist_new_date(st.st_mtime - MAC_EPOCH, 0)); plist_dict_set_item(dirlist, ep->d_name, fdict); free(fpath); -- cgit v1.1-32-gdbae