Skip to content

Commit 1609db8

Browse files
committed
use memcpy instead of strcpy to set rpath
Since we already no the size, this is faster.
1 parent 0121f5e commit 1609db8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/patchelf.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op,
14571457

14581458
/* Zero out the previous rpath to prevent retained dependencies in
14591459
Nix. */
1460-
unsigned int rpathSize = 0;
1460+
size_t rpathSize = 0;
14611461
if (rpath) {
14621462
rpathSize = strlen(rpath);
14631463
memset(rpath, 'X', rpathSize);
@@ -1466,8 +1466,9 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op,
14661466
debug("new rpath is '%s'\n", newRPath.c_str());
14671467

14681468

1469-
if (newRPath.size() <= rpathSize) {
1470-
strcpy(rpath, newRPath.c_str());
1469+
size_t newSize = newRPath.size();
1470+
if (newSize <= rpathSize) {
1471+
memcpy(rpath, newRPath.c_str(), newSize + 1);
14711472
return;
14721473
}
14731474

0 commit comments

Comments
 (0)