Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segmentation faults and items with ID 0 #686

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 57 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.1)
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.1)
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake > 2.8.4 is required
cmake_minimum_required(VERSION 2.8)
ELSE()
else()
cmake_minimum_required(VERSION 3.1)
ENDIF()
endif()

project(lpass)
include(GNUInstallDirs)
find_package(PkgConfig REQUIRED)

IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.4)
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.4)
# pkg_get_variable is not available until CMake >= 3.4.0
# Debian oldstable still packages CMake 3.0.2
function(pkg_get_variable _output_name _pkg _name)
Expand All @@ -25,19 +25,64 @@ IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.4)
set(BASH_COMPLETION_FOUND TRUE)
endif()

ELSE()
else()

include(FindPkgConfig)
pkg_search_module(BASH_COMPLETION bash-completion)

ENDIF()

if((APPLE) AND (NOT DEFINED OPENSSL_ROOT_DIR))
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif()

if((APPLE))
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/curl/lib/pkgconfig")
if(APPLE)
find_program(BREW_INSTALLED BREW)

if(BREW_INSTALLED)
function(get_brew_packageconfig_path _package_name _output_variable)
execute_process(COMMAND brew --cellar ${_package_name}
RESULT_VARIABLE _result_var_cellar
OUTPUT_VARIABLE _output_variable_cellar
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(_result_var_cellar AND NOT STATUS EQUAL 0)
message(STATUS "Unable to obtain homebrew cellar location for package ${_package_name}. Error: ${_result_var_cellar}")
else()
execute_process(COMMAND find "${_output_variable_cellar}/" -type d -name pkgconfig
COMMAND tr -d '\n'
COMMAND tr -s '/'
RESULT_VARIABLE _brew_pkgconfig_c
OUTPUT_VARIABLE _brew_pkgconfig_cellar
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

execute_process(COMMAND brew --prefix ${_package_name}
RESULT_VARIABLE _result_var_prefix
OUTPUT_VARIABLE _output_variable_prefix
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(_result_var_prefix AND NOT STATUS EQUAL 0)
message(STATUS "Unable to obtain homebrew prefix location for package ${_package_name}. Error: ${_result_var_cellar}")
else()
execute_process(COMMAND find "${_output_variable_prefix}/" -type d -name pkgconfig
COMMAND tr -d '\n'
COMMAND tr -s '/'
RESULT_VARIABLE _brew_pkgconfig_p
OUTPUT_VARIABLE _brew_pkgconfig_prefix
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

set("${_output_variable}" "${_brew_pkgconfig_cellar}:${_brew_pkgconfig_prefix}" CACHE STRING "pkg-config homebrew locations for ${_package_name}")

endfunction()

# Get pkg-config paths for curl/openssl installed via homebrew
get_brew_packageconfig_path("curl" BREW_CURL)
get_brew_packageconfig_path("openssl" BREW_OPENSSL)

set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl:${BREW_CURL}:${BREW_OPENSSL}")
message(STATUS "PKG_CONFIG_PATH: $ENV{PKG_CONFIG_PATH}")
else()
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl")
endif()

endif()

find_package(LibXml2 REQUIRED)
Expand Down Expand Up @@ -136,4 +181,4 @@ add_custom_target(doc-man DEPENDS lpass.1)
add_custom_target(doc-html DEPENDS lpass.1.html)
# See https://cmake.org/pipermail/cmake/2009-January/026520.html
add_custom_target(install-doc COMMAND ${CMAKE_COMMAND} -DMANDIR=${CMAKE_INSTALL_FULL_MANDIR} -P ${CMAKE_SOURCE_DIR}/cmake_extras/install_doc.cmake DEPENDS doc-man)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -DPROJECT_NAME=${PROJECT_NAME} -DMANDIR=${CMAKE_INSTALL_FULL_MANDIR} -P ${CMAKE_SOURCE_DIR}/cmake_extras/uninstall.cmake)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -DPROJECT_NAME=${PROJECT_NAME} -DMANDIR=${CMAKE_INSTALL_FULL_MANDIR} -P ${CMAKE_SOURCE_DIR}/cmake_extras/uninstall.cmake)
5 changes: 0 additions & 5 deletions upload-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,6 @@ static void upload_queue_run(const struct session *session, unsigned const char
signal(SIGALRM, upload_queue_cleanup);
setvbuf(stdout, NULL, _IOLBF, 0);

if (http_init()) {
lpass_log(LOG_ERROR, "UQ: unable to restart curl\n");
_exit(EXIT_FAILURE);
}

lpass_log(LOG_DEBUG, "UQ: starting queue run\n");
upload_queue_upload_all(session, key);
lpass_log(LOG_DEBUG, "UQ: queue run complete\n");
Expand Down