1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Fixed a possible crash when moving a recording between different volumes

This commit is contained in:
Klaus Schmidinger 2017-11-27 14:09:04 +01:00
parent 9d5ce204aa
commit 91774cf074
3 changed files with 21 additions and 5 deletions

View File

@ -3283,6 +3283,7 @@ Matthias Senzel <matthias.senzel@t-online.de>
for the "jumpingseconds" patch for the "jumpingseconds" patch
for reporting a bug in drawing very long menu titles in the LCARS skin for reporting a bug in drawing very long menu titles in the LCARS skin
for reporting and helping to debug a crash when stopping VDR for reporting and helping to debug a crash when stopping VDR
for reporting a crash when moving a recording between different volumes
Marek Nazarko <mnazarko@gmail.com> Marek Nazarko <mnazarko@gmail.com>
for translating OSD texts to the Polish language for translating OSD texts to the Polish language

View File

@ -9162,7 +9162,7 @@ Video Disk Recorder Revision History
a subdirectory. a subdirectory.
- SVDRP peering can now be limited to the default SVDRP host (see MANUAL for details). - SVDRP peering can now be limited to the default SVDRP host (see MANUAL for details).
2017-11-26: Version 2.3.9 2017-11-27: Version 2.3.9
- Updated the Italian OSD texts (thanks to Diego Pierotto). - Updated the Italian OSD texts (thanks to Diego Pierotto).
- Updated the Finnish OSD texts (thanks to Rolf Ahrenberg). - Updated the Finnish OSD texts (thanks to Rolf Ahrenberg).
@ -9208,3 +9208,5 @@ Video Disk Recorder Revision History
- Now calling Hide() and cStatus::MsgReplaying(..., false) from cReplayControl::Stop(), - Now calling Hide() and cStatus::MsgReplaying(..., false) from cReplayControl::Stop(),
to inform plugins about an ending replay session before the replay control gets to inform plugins about an ending replay session before the replay control gets
destroyed. destroyed.
- Fixed a possible crash when moving a recording between different volumes (reported by
Matthias Senzel).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: recording.c 4.10 2017/06/25 12:31:46 kls Exp $ * $Id: recording.c 4.11 2017/11/27 13:58:34 kls Exp $
*/ */
#include "recording.h" #include "recording.h"
@ -1725,6 +1725,7 @@ void cDirCopier::Action(void)
int From = -1; int From = -1;
int To = -1; int To = -1;
size_t BufferSize = BUFSIZ; size_t BufferSize = BUFSIZ;
uchar *Buffer = NULL;
while (Running()) { while (Running()) {
// Suspend copying if we have severe throughput problems: // Suspend copying if we have severe throughput problems:
if (Throttled()) { if (Throttled()) {
@ -1734,8 +1735,11 @@ void cDirCopier::Action(void)
// Copy all files in the source directory to the destination directory: // Copy all files in the source directory to the destination directory:
if (e) { if (e) {
// We're currently copying a file: // We're currently copying a file:
uchar Buffer[BufferSize]; if (!Buffer) {
size_t Read = safe_read(From, Buffer, sizeof(Buffer)); esyslog("ERROR: no buffer");
break;
}
size_t Read = safe_read(From, Buffer, BufferSize);
if (Read > 0) { if (Read > 0) {
size_t Written = safe_write(To, Buffer, Read); size_t Written = safe_write(To, Buffer, Read);
if (Written != Read) { if (Written != Read) {
@ -1784,7 +1788,14 @@ void cDirCopier::Action(void)
break; break;
} }
dsyslog("copying file '%s' to '%s'", *FileNameSrc, *FileNameDst); dsyslog("copying file '%s' to '%s'", *FileNameSrc, *FileNameDst);
if (!Buffer) {
BufferSize = max(size_t(st.st_blksize * 10), size_t(BUFSIZ)); BufferSize = max(size_t(st.st_blksize * 10), size_t(BUFSIZ));
Buffer = MALLOC(uchar, BufferSize);
if (!Buffer) {
esyslog("ERROR: out of memory");
break;
}
}
if (access(FileNameDst, F_OK) == 0) { if (access(FileNameDst, F_OK) == 0) {
esyslog("ERROR: destination file '%s' already exists", *FileNameDst); esyslog("ERROR: destination file '%s' already exists", *FileNameDst);
break; break;
@ -1801,11 +1812,13 @@ void cDirCopier::Action(void)
} }
else { else {
// We're done: // We're done:
free(Buffer);
dsyslog("done copying directory '%s' to '%s'", *dirNameSrc, *dirNameDst); dsyslog("done copying directory '%s' to '%s'", *dirNameSrc, *dirNameDst);
error = false; error = false;
return; return;
} }
} }
free(Buffer);
close(From); // just to be absolutely sure close(From); // just to be absolutely sure
close(To); close(To);
esyslog("ERROR: copying directory '%s' to '%s' ended prematurely", *dirNameSrc, *dirNameDst); esyslog("ERROR: copying directory '%s' to '%s' ended prematurely", *dirNameSrc, *dirNameDst);