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 possible buffer overflow in ClpSimplexOther #1

Open
wants to merge 6 commits into
base: stable/1.17
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Project Files unneeded by docker
ci/cache
ci/docker
.git
.gitignore
.github
.dockerignore
.travis.yml
.clang-format
AUTHORS
INSTALL
install-sh
missing
README
README.md

build/

# Editor directories and files
*.user
*.swp
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.swp
.vs/
build/
cache/
106 changes: 106 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
cmake_minimum_required(VERSION 3.15)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# option() honors normal variables.
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

# MSVC runtime library flags are selected by an abstraction.
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

include(ParseAc)
parse_ac(VERSION MAJOR MINOR PATCH)

project(Clp VERSION ${VERSION})

# config options
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)

option(BUILD_SHARED_LIBS "" ON)
if(BUILD_SHARED_LIBS AND MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif(BUILD_SHARED_LIBS AND MSVC)

# config options
if(MSVC)
# Build with multiple processes
add_definitions(/MP)
add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE)
# MSVC warning suppressions
add_definitions(
/wd4018 # 'expression' : signed/unsigned mismatch
/wd4065 # switch statement contains 'default' but no 'case' labels
/wd4101 # 'identifier' : unreferenced local variable
/wd4102 # 'label' : unreferenced label
/wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
/wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
/wd4309 # 'conversion' : truncation of constant value
/wd4805 # 'operation' : unsafe mix of type 'type1' and type 'type2' in operation.
/wd4996 # The compiler encountered a deprecated declaration.
)
endif()
if(APPLE)
set(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override -Wno-unused-command-line-argument -Wno-unused-result -Wno-exceptions"
)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
endif(APPLE)

# ZLIB
if(NOT TARGET ZLIB::ZLIB)
find_package(ZLIB)
endif()
if(ZLIB_FOUND OR TARGET ZLIB::ZLIB)
message(STATUS "Use zlib")
set(HAVE_ZLIB_H "1" CACHE INTERNAL "Use zlib")
set(COIN_HAS_ZLIB "1" CACHE INTERNAL "Use zlib")
endif()

# PThread
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
if(CMAKE_USE_PTHREADS_INIT)
set(PTHREADS_FOUND TRUE)
else()
set(PTHREADS_FOUND FALSE)
endif()

# CoinUtils
if(NOT TARGET Coin::CoinUtils)
find_package(CoinUtils REQUIRED CONFIG)
endif()
# Osi
if(NOT TARGET Coin::Osi)
find_package(Osi REQUIRED CONFIG)
endif()

include(CheckEnv)
include(CTest)

add_subdirectory(Clp)

include(GNUInstallDirs)
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE Coin::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/Config.cmake.in
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY SameMajorVersion)
install(
FILES
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT Devel)
236 changes: 236 additions & 0 deletions Clp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
set(NAME "CLP")

# PTHREAD
if(PTHREADS_FOUND)
set(${NAME}_PTHREADS "1" CACHE INTERNAL "Use pthread")
endif()

set(COIN_${NAME}_CHECKLEVEL "0" CACHE INTERNAL
"${NAME} check level")
set(COIN_${NAME}_VERBOSITY "0" CACHE INTERNAL
"${NAME} verbosity level")
configure_file(config.h.cmake.in config.h)
configure_file(config_clp.h.cmake.in config_clp.h)

set(_SRCS
src/ClpCholeskyBase.cpp
src/ClpCholeskyDense.cpp
src/ClpConstraint.cpp
src/ClpConstraintLinear.cpp
src/ClpConstraintQuadratic.cpp
src/ClpDualRowDantzig.cpp
src/ClpDualRowPivot.cpp
src/ClpDualRowSteepest.cpp
src/ClpDummyMatrix.cpp
src/ClpDynamicExampleMatrix.cpp
src/ClpDynamicMatrix.cpp
src/ClpEventHandler.cpp
src/ClpFactorization.cpp
src/ClpGubDynamicMatrix.cpp
src/ClpGubMatrix.cpp
src/ClpHelperFunctions.cpp
src/ClpInterior.cpp
src/ClpLinearObjective.cpp
src/ClpLsqr.cpp
src/ClpMatrixBase.cpp
src/ClpMessage.cpp
src/ClpModel.cpp
src/ClpNetworkBasis.cpp
src/ClpNetworkMatrix.cpp
src/ClpNode.cpp
src/ClpNonLinearCost.cpp
src/ClpObjective.cpp
src/ClpPEDualRowDantzig.cpp
src/ClpPEDualRowSteepest.cpp
src/ClpPEPrimalColumnDantzig.cpp
src/ClpPEPrimalColumnSteepest.cpp
src/ClpPESimplex.cpp
src/ClpPackedMatrix.cpp
src/ClpPdco.cpp
src/ClpPdcoBase.cpp
src/ClpPlusMinusOneMatrix.cpp
src/ClpPredictorCorrector.cpp
src/ClpPresolve.cpp
src/ClpPrimalColumnDantzig.cpp
src/ClpPrimalColumnPivot.cpp
src/ClpPrimalColumnSteepest.cpp
src/ClpQuadraticObjective.cpp
src/ClpSimplex.cpp
src/ClpSimplexDual.cpp
src/ClpSimplexNonlinear.cpp
src/ClpSimplexOther.cpp
src/ClpSimplexPrimal.cpp
src/ClpSolve.cpp
src/Clp_C_Interface.cpp
src/IdiSolve.cpp
src/Idiot.cpp
)

set(_HDRS
src/ClpCholeskyBase.hpp
src/ClpCholeskyDense.hpp
src/ClpConfig.h
src/ClpConstraint.hpp
src/ClpConstraintLinear.hpp
src/ClpConstraintQuadratic.hpp
src/ClpDualRowDantzig.hpp
src/ClpDualRowPivot.hpp
src/ClpDualRowSteepest.hpp
src/ClpDummyMatrix.hpp
src/ClpDynamicExampleMatrix.hpp
src/ClpDynamicMatrix.hpp
src/ClpEventHandler.hpp
src/ClpFactorization.hpp
src/ClpGubDynamicMatrix.hpp
src/ClpGubMatrix.hpp
src/ClpInterior.hpp
src/ClpLinearObjective.hpp
src/ClpMatrixBase.hpp
src/ClpMessage.hpp
src/ClpModel.hpp
src/ClpNetworkMatrix.hpp
src/ClpNode.hpp
src/ClpNonLinearCost.hpp
src/ClpObjective.hpp
src/ClpPackedMatrix.hpp
src/ClpParameters.hpp
src/ClpPdcoBase.hpp
src/ClpPdco.hpp
src/ClpPEDualRowDantzig.hpp
src/ClpPEDualRowSteepest.hpp
src/ClpPEPrimalColumnDantzig.hpp
src/ClpPEPrimalColumnSteepest.hpp
src/ClpPESimplex.hpp
src/ClpPlusMinusOneMatrix.hpp
src/ClpPresolve.hpp
src/ClpPrimalColumnDantzig.hpp
src/ClpPrimalColumnPivot.hpp
src/ClpPrimalColumnSteepest.hpp
src/ClpQuadraticObjective.hpp
src/ClpSimplex.hpp
src/ClpSimplexDual.hpp
src/ClpSimplexNonlinear.hpp
src/ClpSimplexOther.hpp
src/ClpSimplexPrimal.hpp
src/ClpSolve.hpp
src/Clp_C_Interface.h
src/Idiot.hpp
)

add_library(Clp ${_SRCS} ${_HDRS})
target_include_directories(Clp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include/coin>)
target_compile_definitions(Clp
PUBLIC HAVE_CONFIG_H
PRIVATE CLP_BUILD COIN_HAS_CLP)
if(CMAKE_VERSION VERSION_LESS "3.8.2")
set_property(TARGET Clp PROPERTY CXX_STANDARD 11)
set_property(TARGET Clp PROPERTY CXX_STANDARD_REQUIRED ON)
else()
target_compile_features(Clp PUBLIC cxx_std_11)
endif()
target_link_libraries(Clp PUBLIC
Coin::CoinUtils
Coin::Osi)
set_target_properties(Clp PROPERTIES
PUBLIC_HEADER "${_HDRS};src/CbcOrClpParam.cpp;${CMAKE_CURRENT_BINARY_DIR}/config_clp.h"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
add_library(Coin::Clp ALIAS Clp)

# Install
include(GNUInstallDirs)
install(TARGETS Clp
EXPORT ${PROJECT_NAME}Targets
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/coin
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

##############
## OsiClp ##
##############
set(_SRCS src/OsiClp/OsiClpSolverInterface.cpp)
set(_HDRS src/OsiClp/OsiClpSolverInterface.hpp)

add_library(OsiClp ${_SRCS} ${_HDRS})
target_include_directories(OsiClp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/OsiClp>
$<INSTALL_INTERFACE:include/coin>)
target_compile_definitions(OsiClp
PUBLIC HAVE_CONFIG_H
PRIVATE CLP_BUILD)
if(CMAKE_VERSION VERSION_LESS "3.8.2")
set_property(TARGET OsiClp PROPERTY CXX_STANDARD 11)
set_property(TARGET OsiClp PROPERTY CXX_STANDARD_REQUIRED ON)
else()
target_compile_features(OsiClp PUBLIC cxx_std_11)
endif()
target_link_libraries(OsiClp PUBLIC
Coin::CoinUtils
Coin::Osi
Coin::Clp)
set_target_properties(OsiClp PROPERTIES
PUBLIC_HEADER "${_HDRS}"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
add_library(Coin::OsiClp ALIAS OsiClp)

# Install
install(TARGETS OsiClp
EXPORT ${PROJECT_NAME}Targets
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/coin
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

#################
## ClpSolver ##
#################
set(_SRCS
src/ClpSolver.cpp
src/CbcOrClpParam.cpp
src/Clp_ampl.cpp
src/MyEventHandler.cpp
src/MyMessageHandler.cpp)

set(_HDRS
src/CbcOrClpParam.hpp
src/Clp_ampl.h
src/MyEventHandler.hpp
src/MyMessageHandler.hpp
src/unitTest.cpp)

add_library(ClpSolver ${_SRCS} ${_HDRS})
target_include_directories(ClpSolver PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/coin>)
target_compile_definitions(ClpSolver
PUBLIC HAVE_CONFIG_H
PRIVATE CLP_BUILD COIN_HAS_CLP)
if(CMAKE_VERSION VERSION_LESS "3.8.2")
set_property(TARGET ClpSolver PROPERTY CXX_STANDARD 11)
set_property(TARGET ClpSolver PROPERTY CXX_STANDARD_REQUIRED ON)
else()
target_compile_features(ClpSolver PUBLIC cxx_std_11)
endif()
target_link_libraries(ClpSolver PUBLIC Coin::Clp)
set_target_properties(ClpSolver PROPERTIES
PUBLIC_HEADER "${_HDRS}"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
add_library(Coin::ClpSolver ALIAS ClpSolver)

# Install
install(TARGETS ClpSolver
EXPORT ${PROJECT_NAME}Targets
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/coin
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

if(BUILD_TESTING)
add_subdirectory(test)
endif()
Loading