Fixed a crash in strreplace() for multiple replacements with strings of different lengths

This commit is contained in:
Klaus Schmidinger 2024-07-10 14:59:45 +02:00
parent 305735a886
commit 87410442b6
3 changed files with 11 additions and 2 deletions

View File

@ -2574,6 +2574,8 @@ Markus Ehrnsperger <markus.ehrnsperger@googlemail.com>
for suggesting to enable unused devices to be put into a power save mode
for a patch that was used to implement power save mode for cDvbDevice
for suggesting to add 'lnbPowerTurnedOn = false' to cDvbTuner::ProvidesFrontend()
for reporting a crash in strreplace() for multiple replacements with strings of
different lengths
Werner Färber <w.faerber@gmx.de>
for reporting a bug in handling the cPluginManager::Active() result when pressing

View File

@ -9939,3 +9939,8 @@ Video Disk Recorder Revision History
Ehrnsperger).
- Added 'lnbPowerTurnedOn = false' to cDvbTuner::ProvidesFrontend() (suggested by
Markus Ehrnsperger).
2024-07-10:
- Fixed a crash in strreplace() for multiple replacements with strings of different
lengths (reported by Markus Ehrnsperger).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: tools.c 5.11 2024/06/21 06:27:20 kls Exp $
* $Id: tools.c 5.12 2024/07/10 14:50:07 kls Exp $
*/
#include "tools.h"
@ -169,8 +169,10 @@ char *strreplace(char *s, const char *s1, const char *s2)
}
}
char *sof = s + of;
if (l2 != l1)
if (l2 != l1) {
memmove(sof + l2, sof + l1, l - of - l1 + 1);
l += l2 - l1;
}
memcpy(sof, s2, l2);
q = sof + l2;
} while (p = strstr(q, s1));