summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/slibtool/slibtool.h6
-rw-r--r--src/internal/slibtool_symlink_impl.c2
-rw-r--r--src/internal/slibtool_symlink_impl.h2
-rw-r--r--src/logic/slbt_exec_install.c11
-rw-r--r--src/logic/slbt_exec_link.c2
-rw-r--r--src/util/slbt_copy_file.c32
6 files changed, 38 insertions, 17 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h
index e3277cc..f6e420c 100644
--- a/include/slibtool/slibtool.h
+++ b/include/slibtool/slibtool.h
@@ -417,10 +417,10 @@ slbt_api int slbt_host_flavor_settings (const char *, const struct slbt_flavor_
slbt_api int slbt_util_import_archive (const struct slbt_exec_ctx *,
char * dstarchive, char * srcarchive);
-slbt_api int slbt_util_create_mapfile (const struct slbt_symlist_ctx *, const char *, mode_t);
+slbt_api int slbt_util_copy_file (struct slbt_exec_ctx *,
+ const char * from, const char * to);
-slbt_api int slbt_util_copy_file (const struct slbt_driver_ctx *, struct slbt_exec_ctx *,
- char * src, char * dst);
+slbt_api int slbt_util_create_mapfile (const struct slbt_symlist_ctx *, const char *, mode_t);
slbt_api int slbt_util_dump_machine (const char * compiler, char * machine, size_t bufsize);
diff --git a/src/internal/slibtool_symlink_impl.c b/src/internal/slibtool_symlink_impl.c
index c9be845..a788800 100644
--- a/src/internal/slibtool_symlink_impl.c
+++ b/src/internal/slibtool_symlink_impl.c
@@ -131,7 +131,7 @@ slbt_hidden int slbt_create_symlink(
: 0;
}
-slbt_hidden int slbt_symlink_is_a_placeholder(int fdcwd, char * lnkpath)
+slbt_hidden int slbt_symlink_is_a_placeholder(int fdcwd, const char * lnkpath)
{
size_t len;
char slink [PATH_MAX];
diff --git a/src/internal/slibtool_symlink_impl.h b/src/internal/slibtool_symlink_impl.h
index fc4c708..14ddead 100644
--- a/src/internal/slibtool_symlink_impl.h
+++ b/src/internal/slibtool_symlink_impl.h
@@ -16,6 +16,6 @@ int slbt_create_symlink(
const char * lnkname,
uint32_t options);
-int slbt_symlink_is_a_placeholder(int fdcwd, char * lnkpath);
+int slbt_symlink_is_a_placeholder(int fdcwd, const char * lnkpath);
#endif
diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c
index 20cf679..ddd3a60 100644
--- a/src/logic/slbt_exec_install.c
+++ b/src/logic/slbt_exec_install.c
@@ -191,7 +191,7 @@ static int slbt_exec_install_import_libraries(
dctx->cctx->asettings.impsuffix);
/* copy: .libs/libfoo.x.y.z.lib.a --> dstdir */
- if (slbt_util_copy_file(dctx,ectx,srcbuf,dstdir))
+ if (slbt_util_copy_file(ectx,srcbuf,dstdir))
return SLBT_NESTED_ERROR(dctx);
/* .libs/libfoo.x.lib.a */
@@ -200,7 +200,7 @@ static int slbt_exec_install_import_libraries(
dctx->cctx->asettings.impsuffix);
/* copy: .libs/libfoo.x.lib.a --> dstdir */
- if (slbt_util_copy_file(dctx,ectx,srcbuf,dstdir))
+ if (slbt_util_copy_file(ectx,srcbuf,dstdir))
return SLBT_NESTED_ERROR(dctx);
/* /dstdir/libfoo.lib.a */
@@ -310,7 +310,7 @@ static int slbt_exec_install_library_wrapper(
slbt_unmap_file(mapinfo);
/* cp libfoo.la.slibtool.instal /dstdir/libfoo.la */
- if (slbt_util_copy_file(dctx,ectx,clainame,instname))
+ if (slbt_util_copy_file(ectx,clainame,instname))
return SLBT_NESTED_ERROR(dctx);
return 0;
@@ -555,7 +555,8 @@ static int slbt_exec_install_entry(
farchive = false;
if (farchive)
- if (slbt_util_copy_file(dctx,ectx,
+ if (slbt_util_copy_file(
+ ectx,
srcfile,
dest ? (char *)dest->arg : *dst))
return SLBT_NESTED_ERROR(dctx);
@@ -683,7 +684,7 @@ static int slbt_exec_install_entry(
if (fpe) {
/* copy: .libs/libfoo.so.x.y.z --> libfoo.so.x */
if (slbt_util_copy_file(
- dctx,ectx,
+ ectx,
srcfile,
dlnkname))
return SLBT_NESTED_ERROR(dctx);
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 4545110..428c13a 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -120,7 +120,7 @@ static int slbt_exec_link_create_library_symlink(
if (fmajor && (dctx->cctx->drvflags & SLBT_DRIVER_IMAGE_PE))
return slbt_util_copy_file(
- dctx,ectx,
+ ectx,
target,lnkname);
else
return slbt_create_symlink(
diff --git a/src/util/slbt_copy_file.c b/src/util/slbt_copy_file.c
index e6868de..3fa0074 100644
--- a/src/util/slbt_copy_file.c
+++ b/src/util/slbt_copy_file.c
@@ -11,24 +11,39 @@
#include "slibtool_errinfo_impl.h"
int slbt_util_copy_file(
- const struct slbt_driver_ctx * dctx,
- struct slbt_exec_ctx * ectx,
- char * src,
- char * dst)
+ struct slbt_exec_ctx * ectx,
+ const char * from,
+ const char * to)
{
+ int ret;
int fdcwd;
char ** oargv;
char * oprogram;
+ char * src;
+ char * dst;
char * cp[4];
- int ret;
+
+ const struct slbt_driver_ctx * dctx;
+
+ /* driver context */
+ dctx = (slbt_get_exec_ictx(ectx))->dctx;
/* fdcwd */
fdcwd = slbt_driver_fdcwd(dctx);
/* placeholder? */
- if (slbt_symlink_is_a_placeholder(fdcwd,src))
+ if (slbt_symlink_is_a_placeholder(fdcwd,from))
return 0;
+ /* until we perform an in-memory copy ... */
+ if (!(src = strdup(from)))
+ return SLBT_SYSTEM_ERROR(dctx,0);
+
+ if (!(dst = strdup(to))) {
+ free(src);
+ return SLBT_SYSTEM_ERROR(dctx,0);
+ }
+
/* cp argv */
cp[0] = "cp";
cp[1] = src;
@@ -47,12 +62,14 @@ int slbt_util_copy_file(
if (slbt_output_link(ectx)) {
ectx->argv = oargv;
ectx->program = oprogram;
+ free(src); free(dst);
return SLBT_NESTED_ERROR(dctx);
}
} else {
if (slbt_output_install(ectx)) {
ectx->argv = oargv;
ectx->program = oprogram;
+ free(src); free(dst);
return SLBT_NESTED_ERROR(dctx);
}
}
@@ -70,6 +87,9 @@ int slbt_util_copy_file(
ret = 0;
}
+ free(src);
+ free(dst);
+
ectx->argv = oargv;
ectx->program = oprogram;
return ret;