Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/elfmz/far2l.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelfmz <fenix1905@tut.by>2022-11-07 10:19:05 +0300
committerelfmz <fenix1905@tut.by>2022-11-07 10:19:05 +0300
commitfa30944de1bd03ca9e2bfdf6ad82085a5b730f59 (patch)
tree8c71630d7b219ad8a958efb2a14814326e224f29
parentc42eba333cf725e615cc01fbb105817aba0389c2 (diff)
copy: add extra failure checks (touch #1387)
-rw-r--r--far2l/src/copy.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/far2l/src/copy.cpp b/far2l/src/copy.cpp
index 5487f4ec..eca74951 100644
--- a/far2l/src/copy.cpp
+++ b/far2l/src/copy.cpp
@@ -2975,14 +2975,17 @@ DWORD ShellFileTransfer::PieceCopy()
if (BytesWritten > BytesRead)
{ // likely we written bit more due to no_buffering requires aligned io
// move backward and correct file size
- _DestFile.SetPointer((INT64)BytesRead - (INT64)WriteSize, nullptr, FILE_CURRENT);
- _DestFile.SetEnd();
+ if (!_DestFile.SetPointer((INT64)BytesRead - (INT64)WriteSize, nullptr, FILE_CURRENT))
+ throw ErrnoSaver();
+ if (!_DestFile.SetEnd())
+ throw ErrnoSaver();
return BytesRead;
}
if (BytesWritten < BytesRead)
{ // if written less than read then need to rewind source file by difference
- _SrcFile.SetPointer((INT64)BytesWritten - (INT64)BytesRead, nullptr, FILE_CURRENT);
+ if (!_SrcFile.SetPointer((INT64)BytesWritten - (INT64)BytesRead, nullptr, FILE_CURRENT))
+ throw ErrnoSaver();
}
return BytesWritten;