|
|
047598 |
--- ntfsprogs/ntfsclone.c 2018-05-16 18:46:47.114964000 +0200
|
|
|
047598 |
+++ ntfsprogs/ntfsclone.c 2018-07-16 14:03:20.273809100 +0200
|
|
|
047598 |
@@ -776,6 +776,10 @@
|
|
|
047598 |
|
|
|
047598 |
/* possible partial cluster holding the backup boot sector */
|
|
|
047598 |
backup_bootsector = (lcn + 1)*csize >= full_device_size;
|
|
|
047598 |
+ buff = (char*)ntfs_malloc(csize);
|
|
|
047598 |
+ if (!buff)
|
|
|
047598 |
+ err_exit("Not enough memory");
|
|
|
047598 |
+
|
|
|
047598 |
if (backup_bootsector) {
|
|
|
047598 |
csize = full_device_size - lcn*csize;
|
|
|
047598 |
if (csize < 0) {
|
|
|
047598 |
@@ -783,10 +787,6 @@
|
|
|
047598 |
}
|
|
|
047598 |
}
|
|
|
047598 |
|
|
|
047598 |
- buff = (char*)ntfs_malloc(csize);
|
|
|
047598 |
- if (!buff)
|
|
|
047598 |
- err_exit("Not enough memory");
|
|
|
047598 |
-
|
|
|
047598 |
// need reading when not about to write ?
|
|
|
047598 |
if (read_all(fd, buff, csize) == -1) {
|
|
|
047598 |
|
|
|
047598 |
@@ -1507,6 +1507,7 @@
|
|
|
047598 |
s64 mft_no;
|
|
|
047598 |
u32 mft_record_size;
|
|
|
047598 |
u32 csize;
|
|
|
047598 |
+ u32 buff_size;
|
|
|
047598 |
u32 bytes_per_sector;
|
|
|
047598 |
u32 records_per_set;
|
|
|
047598 |
u32 clusters_per_set;
|
|
|
047598 |
@@ -1524,15 +1525,18 @@
|
|
|
047598 |
/*
|
|
|
047598 |
* Depending on the sizes, there may be several records
|
|
|
047598 |
* per cluster, or several clusters per record.
|
|
|
047598 |
+ * Anyway, full clusters are needed for rescuing bad ones.
|
|
|
047598 |
*/
|
|
|
047598 |
if (csize >= mft_record_size) {
|
|
|
047598 |
records_per_set = csize/mft_record_size;
|
|
|
047598 |
clusters_per_set = 1;
|
|
|
047598 |
+ buff_size = csize;
|
|
|
047598 |
} else {
|
|
|
047598 |
clusters_per_set = mft_record_size/csize;
|
|
|
047598 |
records_per_set = 1;
|
|
|
047598 |
+ buff_size = mft_record_size;
|
|
|
047598 |
}
|
|
|
047598 |
- buff = (char*)ntfs_malloc(mft_record_size);
|
|
|
047598 |
+ buff = (char*)ntfs_malloc(buff_size);
|
|
|
047598 |
if (!buff)
|
|
|
047598 |
err_exit("Not enough memory");
|
|
|
047598 |
|
|
|
047598 |
@@ -1585,6 +1589,7 @@
|
|
|
047598 |
void *fd;
|
|
|
047598 |
u32 indx_record_size;
|
|
|
047598 |
u32 csize;
|
|
|
047598 |
+ u32 buff_size;
|
|
|
047598 |
u32 bytes_per_sector;
|
|
|
047598 |
u32 records_per_set;
|
|
|
047598 |
u32 clusters_per_set;
|
|
|
047598 |
@@ -1601,16 +1606,19 @@
|
|
|
047598 |
/*
|
|
|
047598 |
* Depending on the sizes, there may be several records
|
|
|
047598 |
* per cluster, or several clusters per record.
|
|
|
047598 |
+ * Anyway, full clusters are needed for rescuing bad ones.
|
|
|
047598 |
*/
|
|
|
047598 |
indx_record_size = image->ni->vol->indx_record_size;
|
|
|
047598 |
if (csize >= indx_record_size) {
|
|
|
047598 |
records_per_set = csize/indx_record_size;
|
|
|
047598 |
clusters_per_set = 1;
|
|
|
047598 |
+ buff_size = csize;
|
|
|
047598 |
} else {
|
|
|
047598 |
clusters_per_set = indx_record_size/csize;
|
|
|
047598 |
records_per_set = 1;
|
|
|
047598 |
+ buff_size = indx_record_size;
|
|
|
047598 |
}
|
|
|
047598 |
- buff = (char*)ntfs_malloc(indx_record_size);
|
|
|
047598 |
+ buff = (char*)ntfs_malloc(buff_size);
|
|
|
047598 |
if (!buff)
|
|
|
047598 |
err_exit("Not enough memory");
|
|
|
047598 |
|