Skip to content

Commit 3fc63c9

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

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/patchelf.cc

+2-2
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);
@@ -1467,7 +1467,7 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op,
14671467

14681468

14691469
if (newRPath.size() <= rpathSize) {
1470-
strcpy(rpath, newRPath.c_str());
1470+
memcpy(rpath, newRPath.c_str(), newRPath.size() + 1);
14711471
return;
14721472
}
14731473

0 commit comments

Comments
 (0)