Skip to content

Commit

Permalink
fix setting empty rpath
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 authored and haampie committed Nov 27, 2021
1 parent 31e9c71 commit 411e004
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/patchelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ void ElfFile<ElfFileParamNames>::modifyRPath(RPathOp op,
debug("new rpath is '%s'\n", newRPath.c_str());


if (newRPath.size() <= rpathSize) {
if (rpath && newRPath.size() <= rpathSize) {
memcpy(rpath, newRPath.c_str(), newRPath.size() + 1);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ src_TESTS = \
invalid-elf.sh \
endianness.sh \
contiguous_note_sections.sh \
no-gnu-hash.sh
no-gnu-hash.sh \
set-empty-rpath.sh

build_TESTS = \
$(no_rpath_arch_TESTS)
Expand Down
11 changes: 11 additions & 0 deletions tests/set-empty-rpath.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/sh -e
SCRATCH=scratch/$(basename $0 .sh)

rm -rf ${SCRATCH}
mkdir -p ${SCRATCH}

cp simple ${SCRATCH}/simple

../src/patchelf --force-rpath --set-rpath "" ${SCRATCH}/simple

${SCRATCH}/simple

0 comments on commit 411e004

Please sign in to comment.