Skip to content

Commit adcab84

Browse files
GongHeng2017deepin-bot[bot]
authored andcommitted
fix: [disk-encrypt] unencrypt part error
The seek pos is greater than part size. add limit for this. Change-Id: I07839506f171858152ce2865f812714769023d9e
1 parent 4a42dcc commit adcab84

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • src/dde-file-manager-daemon/daemonplugin-file-encrypt/encrypt

src/dde-file-manager-daemon/daemonplugin-file-encrypt/encrypt/diskencrypt.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ bool block_device_utils::bcMoveFsForward(const QString &device)
929929
return false;
930930
}
931931
quint64 mvCount = partSize / kStepSize;
932-
if (partSize % kStepSize) mvCount += 1;
932+
if (partSize % kStepSize == 0) mvCount -= 1;
933933

934934
// read break point.
935935
auto records = logFile.readAll().split(',');
@@ -942,6 +942,11 @@ bool block_device_utils::bcMoveFsForward(const QString &device)
942942
quint64 currMovedIndex = lastMovedIndex + 1;
943943
for (; currMovedIndex <= mvCount; ++currMovedIndex, ++lastMovedIndex) {
944944
// qInfo() << "moving..." << currMovedIndex << device;
945+
if (currMovedIndex * kStepSize >= partSize) {
946+
qWarning() << "The seek pos is greater than part size!";
947+
clearMem();
948+
break;
949+
}
945950
// seek current move position
946951
if (!blockFile.seek(currMovedIndex * kStepSize)) {
947952
qWarning() << "seek pos failed!" << currMovedIndex * kStepSize;

0 commit comments

Comments
 (0)