diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-29 01:35:09 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-29 01:35:09 -0500 |
commit | 4595ada2f69b42670c85a63c7d2344af63f2afe7 (patch) | |
tree | 0d528d8177aceefcf74fb7306fc0fc7cc3c41ece /src/rpath.c | |
parent | 8ae4f8f5985445b1ce3547975f407847c0fee0f7 (diff) | |
download | spmc-4595ada2f69b42670c85a63c7d2344af63f2afe7.tar.gz |
Minor fixes:
* size_t in place of int
* Moved some variables closer to their execution scope
* Add some error checks
Diffstat (limited to 'src/rpath.c')
-rw-r--r-- | src/rpath.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/rpath.c b/src/rpath.c index 99d3403..1d32ae7 100644 --- a/src/rpath.c +++ b/src/rpath.c @@ -43,9 +43,6 @@ int has_rpath(const char *_filename) { return -1; } - Process *proc_info = NULL; - char *rpath = NULL; - // sanitize input path strchrdel(filename, "&;|"); @@ -87,7 +84,6 @@ char *rpath_get(const char *_filename) { return NULL; } - Process *proc_info = NULL; char *rpath = NULL; // sanitize input path @@ -145,7 +141,7 @@ char *rpath_generate(const char *_filename) { * @return */ int rpath_set(const char *filename, char *_rpath) { - int returncode; + int returncode = 0; char *rpath_new = rpath_generate(filename); if (!rpath_new) { @@ -164,14 +160,18 @@ int rpath_set(const char *filename, char *_rpath) { return 0; } - Process *pe = patchelf(filename, "--set-rpath"); - if (pe) { + char args[PATH_MAX]; + memset(args, '\0', PATH_MAX); + sprintf(args, "--set-rpath \"%s\"", _rpath); + + Process *pe = patchelf(filename, args); + if (pe != NULL) { returncode = pe->returncode; } shell_free(pe); free(rpath_new); free(rpath_orig); - return pe->returncode; + return returncode; } /** |