From a5680056ce5eaa0da970da81dc611a999cd38811 Mon Sep 17 00:00:00 2001 From: Maximiato Date: Wed, 26 Sep 2018 20:57:34 -0700 Subject: [PATCH 1/2] Issue #10 -- unix lib.rs passes non zero terminated strings to dlopen Converting to CString type before passing as a C pointer to dlopen added the \0 termination and obviates one of the casts. Tests would fail if the same rigor was applied to dlsym because optional \0 termination is used as a feature (see example calls of find_func() in lib_impl/lib.rs). --- src/os/unix/lib.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/os/unix/lib.rs b/src/os/unix/lib.rs index d050e45ec..173c03e3a 100755 --- a/src/os/unix/lib.rs +++ b/src/os/unix/lib.rs @@ -3,6 +3,7 @@ use os::unix::external; use os::unix::OkOrDlerror; use os::unix::RTLD_LAZY; use util; +use std::ffi::CString; use std::mem; use std::path::Path; use std::os::raw::c_char; @@ -16,15 +17,13 @@ pub struct Lib { impl Lib { pub unsafe fn new(path_to_lib: TPath) -> Result where TPath: AsRef { - let path_to_lib_str = - path_to_lib - .as_ref() - .to_string_lossy(); - let path_to_lib_c_str = path_to_lib_str.as_ptr() as *const c_char; + let path_to_lib_c_str = CString::new(path_to_lib.as_ref().to_string_lossy().as_ref()) + .chain_err( || ErrorKind::LibraryOpen(path_to_lib.as_ref().to_path_buf()))?; + let path_to_lib_c_ptr = path_to_lib_c_str.as_ptr(); util::error_guard( || { - let result = external::dlopen(path_to_lib_c_str, RTLD_LAZY); + let result = external::dlopen(path_to_lib_c_ptr, RTLD_LAZY); if result.is_null() { None From 64d59a4238f831c4a5c531580d0ab2a6b1e2ec88 Mon Sep 17 00:00:00 2001 From: Hugo van der Wijst Date: Tue, 4 Dec 2018 21:03:30 -0800 Subject: [PATCH 2/2] Upgrade to Gradle 5.0. --- gradle/wrapper/gradle-wrapper.properties | 2 +- test/examplelib/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 58b35d1a7..de9238263 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip diff --git a/test/examplelib/build.gradle b/test/examplelib/build.gradle index 18c727d03..eea683dd5 100644 --- a/test/examplelib/build.gradle +++ b/test/examplelib/build.gradle @@ -3,7 +3,7 @@ rsFiles.include "**/*.rs" task cargoBuild(type: Exec) { commandLine "cargo", "build" - inputs.file(rsFiles) + inputs.files(rsFiles) outputs.file("target/debug/examplelib.dll") }