Fix LLP64 JSON bounds and fully omit disabled build dependencies

This commit is contained in:
Max Lv
2026-09-11 00:25:43 +08:00
parent 118d2e8ddf
commit 46d3acd9d6
5 changed files with 22 additions and 5 deletions
+2
View File
@@ -1,4 +1,5 @@
include(CMakePackageConfigHelpers)
if(SS_BUILD_STATIC_LIBRARY OR SS_BUILD_SHARED_LIBRARY)
set(SS_SYSTEM_DEPENDENCIES "")
set(SS_PC_PRIVATE "")
set(private_links)
@@ -68,6 +69,7 @@ configure_file(cmake/shadowsocks-libev.pc.cmake "${CMAKE_CURRENT_BINARY_DIR}/pac
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/shadowsocks-libev.pc"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/package/shadowsocks-libev.pc.in")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/shadowsocks-libev.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
install(FILES COPYING LICENSE third_party/README.md third_party/manifest.json
DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/shadowsocks-libev)
+3 -1
View File
@@ -166,4 +166,6 @@ foreach(kind STATIC SHARED)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endforeach()
install(FILES shadowsocks.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if(SS_BUILD_STATIC_LIBRARY OR SS_BUILD_SHARED_LIBRARY)
install(FILES shadowsocks.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
+5 -4
View File
@@ -778,9 +778,10 @@ json_value * json_parse_ex (json_settings * settings,
}
/* Overflow check for integer */
long prev = top->u.integer;
if ((prev > 0 && (prev > (LONG_MAX / 10) || (prev == (LONG_MAX / 10) && (b - '0') > (LONG_MAX % 10)))) ||
(prev < 0 && (prev < (LONG_MIN / 10) || (prev == (LONG_MIN / 10) && -(b - '0') < (LONG_MIN % 10))))) {
json_int_t prev = top->u.integer;
/* Digits accumulate as a positive int64_t magnitude;
* long is only 32 bits on LLP64 platforms such as Windows. */
if (prev > (INT64_MAX / 10) || (prev == (INT64_MAX / 10) && (b - '0') > (INT64_MAX % 10))) {
sprintf(error, "%d:%d: Integer too large (overflow)", line_and_col);
goto e_failed;
}
@@ -789,7 +790,7 @@ json_value * json_parse_ex (json_settings * settings,
}
/* Overflow check for fraction */
if (num_fraction > (LONG_MAX / 10) || (num_fraction == (LONG_MAX / 10) && (b - '0') > (LONG_MAX % 10))) {
if (num_fraction > (INT64_MAX / 10) || (num_fraction == (INT64_MAX / 10) && (b - '0') > (INT64_MAX % 10))) {
sprintf(error, "%d:%d: Fraction too large (overflow)", line_and_col);
goto e_failed;
}
+9
View File
@@ -139,6 +139,15 @@ test_parse_empty_array(void)
int
main(void)
{
const char *wide_numbers = "[4294967296,9223372036854775807,-4294967296,0.4294967296]";
json_value *wide = json_parse(wide_numbers, strlen(wide_numbers));
assert(wide != NULL && wide->type == json_array && wide->u.array.length == 4);
assert(wide->u.array.values[0]->u.integer == INT64_C(4294967296));
assert(wide->u.array.values[1]->u.integer == INT64_MAX);
assert(wide->u.array.values[2]->u.integer == -INT64_C(4294967296));
assert(wide->u.array.values[3]->u.dbl > 0.4294967295 && wide->u.array.values[3]->u.dbl < 0.4294967297);
json_value_free(wide);
assert(json_parse("9223372036854775808", 19) == NULL);
test_parse_simple_object();
test_parse_array();
test_parse_nested();
+3
View File
@@ -7,6 +7,9 @@ foreach(i RANGE ${last})
foreach(field name archive sha256)
string(JSON ${field} GET "${manifest}" ${i} ${field})
endforeach()
if(name STREQUAL "pcre2" AND NOT SS_ENABLE_REGEX)
continue()
endif()
set(archive_path "${CMAKE_CURRENT_SOURCE_DIR}/dist/${archive}")
file(SHA256 "${archive_path}" actual)
if(NOT actual STREQUAL sha256)