From 3fc63c945c8c1adf6593c5d4b912a637ccdcf8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 18 Aug 2021 08:26:11 +0200 Subject: [PATCH] use memcpy instead of strcpy to set rpath Since we already no the size, this is faster. --- src/patchelf.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/patchelf.cc b/src/patchelf.cc index 1080e6b6..985caf0d 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -1457,7 +1457,7 @@ void ElfFile::modifyRPath(RPathOp op, /* Zero out the previous rpath to prevent retained dependencies in Nix. */ - unsigned int rpathSize = 0; + size_t rpathSize = 0; if (rpath) { rpathSize = strlen(rpath); memset(rpath, 'X', rpathSize); @@ -1467,7 +1467,7 @@ void ElfFile::modifyRPath(RPathOp op, if (newRPath.size() <= rpathSize) { - strcpy(rpath, newRPath.c_str()); + memcpy(rpath, newRPath.c_str(), newRPath.size() + 1); return; }