Build: update 3.6 libraries to address CVEs and bugs #112528

Merged
Brecht Van Lommel merged 11 commits from brecht/blender:fix-cves-3.6 into blender-v3.6-release 2023-10-09 14:24:44 +02:00
12 changed files with 103 additions and 18 deletions
Showing only changes of commit ad020c2b95 - Show all commits

View File

@ -15,15 +15,16 @@ check_symbol_exists(malloc_stats "malloc.h" HAVE_MALLOC_STATS_H)
# Used for: `source/creator/creator_signals.c`.
# The function `feenableexcept` is not present non-GLIBC systems,
# hence we need to check if it's available in the `fenv.h` file.
set(HAVE_FEENABLEEXCEPT OFF)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
check_symbol_exists(feenableexcept "fenv.h" HAVE_FEENABLEEXCEPT)
endif()
if(NOT DEFINED HAVE_FEENABLEEXCEPT)
set(HAVE_FEENABLEEXCEPT 0)
endif()
# Used for: `source/blender/blenlib/intern/system.c`.
# `execinfo` is not available on non-GLIBC systems (at least not on MUSL-LIBC),
# so check the presence of the header before including it and using the it for back-trace.
set(HAVE_EXECINFO_H OFF)
if(NOT MSVC)
include(CheckIncludeFiles)
check_include_files("execinfo.h" HAVE_EXECINFO_H)
@ -31,3 +32,6 @@ if(NOT MSVC)
add_definitions(-DHAVE_EXECINFO_H)
endif()
endif()
if(NOT DEFINED HAVE_EXECINFO_H)
set(HAVE_EXECINFO_H 0)
endif()

View File

@ -3,6 +3,8 @@
#pragma once
#include "util/hash.h"
CCL_NAMESPACE_BEGIN
/* Linear Congruential Generator */
@ -35,7 +37,7 @@ ccl_device_inline uint lcg_state_init(const uint rng_hash,
const uint sample,
const uint scramble)
{
return lcg_init(rng_hash + rng_offset + sample * scramble);
return hash_uint3(rng_hash ^ scramble, rng_offset, sample);
}
CCL_NAMESPACE_END

View File

@ -319,8 +319,15 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures,
unsigned int height = 0;
GpuShaderCreator::TextureType channel = GpuShaderCreator::TEXTURE_RGB_CHANNEL;
Interpolation interpolation = INTERP_LINEAR;
#if OCIO_VERSION_HEX >= 0x02030000
/* Always use 2D textures in OpenColorIO 2.3, simpler and same performance. */
GpuShaderDesc::TextureDimensions dimensions = GpuShaderDesc::TEXTURE_2D;
shader_desc->getTexture(
index, texture_name, sampler_name, width, height, channel, dimensions, interpolation);
#else
shader_desc->getTexture(
index, texture_name, sampler_name, width, height, channel, interpolation);
#endif
const float *values;
shader_desc->getTextureValues(index, values);
@ -334,6 +341,7 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures,
GPU_R16F;
OCIO_GPULutTexture lut;
#if OCIO_VERSION_HEX < 0x02030000
/* There does not appear to be an explicit way to check if a texture is 1D or 2D.
* It depends on more than height. So check instead by looking at the source. */
std::string sampler1D_name = std::string("sampler1D ") + sampler_name;
@ -341,7 +349,9 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures,
lut.texture = GPU_texture_create_1d(
texture_name, width, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values);
}
else {
else
#endif
{
lut.texture = GPU_texture_create_2d(
texture_name, width, height, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values);
}

View File

@ -21,7 +21,7 @@ extern "C" {
/* Blender major and minor version. */
#define BLENDER_VERSION 306
/* Blender patch version for bugfix releases. */
#define BLENDER_VERSION_PATCH 3
#define BLENDER_VERSION_PATCH 5
/** Blender release cycle stage: alpha/beta/rc/release. */
#define BLENDER_VERSION_CYCLE rc

View File

@ -731,13 +731,13 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph,
continue;
}
blender::bke::ScopedModifierTimer modifier_timer{*md};
if (md->type == eModifierType_Nodes) {
mti->modifyGeometrySet(md, &mectx_apply, &geometry_set);
continue;
}
blender::bke::ScopedModifierTimer modifier_timer{*md};
if (!geometry_set.has_mesh()) {
geometry_set.replace_mesh(BKE_mesh_new_nomain(0, 0, 0, 0));
}

View File

@ -271,6 +271,19 @@ static size_t id_delete(Main *bmain,
* code has some specific handling of 'no main' IDs that would be a problem in that
* case). */
id->tag |= tag;
/* Forcefully also delete shapekeys of the deleted ID if any, 'orphaned' shapekeys are
* not allowed in Blender and will cause lots of problem in modern code (liboverrides,
* warning on write & read, etc.). */
Key *shape_key = BKE_key_from_id(id);
if (shape_key && (shape_key->id.tag & tag) == 0) {
BLI_remlink(&bmain->shapekeys, &shape_key->id);
BKE_main_namemap_remove_name(bmain, &shape_key->id, shape_key->id.name + 2);
BLI_addtail(&tagged_deleted_ids, &shape_key->id);
BKE_id_remapper_add(id_remapper, &shape_key->id, NULL);
shape_key->id.tag |= tag;
}
keep_looping = true;
}
}

View File

@ -93,6 +93,18 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
return GPU_max_texture_size();
}
# if OCIO_VERSION_HEX >= 0x02030000
void setAllowTexture1D(bool allowed) override
{
allow_texture_1D_ = allowed;
}
bool getAllowTexture1D() const override
{
return allow_texture_1D_;
}
# endif
bool addUniform(const char *name, const DoubleGetter &get_double) override
{
/* Check if a resource exists with the same name and assert if it is the case, returning false
@ -199,6 +211,9 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
unsigned width,
unsigned height,
TextureType channel,
# if OCIO_VERSION_HEX >= 0x02030000
OCIO::GpuShaderDesc::TextureDimensions dimensions,
# endif
OCIO::Interpolation interpolation,
const float *values) override
{
@ -214,7 +229,11 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
GPUTexture *texture;
eGPUTextureFormat texture_format = (channel == TEXTURE_RGB_CHANNEL) ? GPU_RGB16F : GPU_R16F;
/* A height of 1 indicates a 1D texture according to the OCIO API. */
# if OCIO_VERSION_HEX >= 0x02030000
if (dimensions == OCIO::GpuShaderDesc::TEXTURE_1D) {
# else
if (height == 1) {
# endif
texture = GPU_texture_create_1d(
texture_name, width, 1, texture_format, GPU_TEXTURE_USAGE_SHADER_READ, values);
shader_create_info_.sampler(textures_.size() + 1, ImageType::FLOAT_1D, resource_name);
@ -396,6 +415,11 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
/* A vectors that stores the created uniform buffers when bind_shader_and_resources() is called,
* so that they can be properly unbound and freed in the unbind_shader_and_resources() method. */
Vector<GPUUniformBuf *> uniform_buffers_;
# if OCIO_VERSION_HEX >= 0x02030000
/* Allow creating 1D textures, or only use 2D textures. */
bool allow_texture_1D_ = true;
# endif
};
#else

View File

@ -46,6 +46,7 @@
#include "ED_transform_snap_object_context.h"
#include "ED_undo.h"
#include "ED_view3d.h"
#include "ED_outliner.h"
#include "WM_toolsystem.h"
@ -475,6 +476,8 @@ static bool object_transfer_mode_to_base(bContext *C, wmOperator *op, Base *base
}
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
ED_outliner_select_sync_from_object_tag(C);
WM_toolsystem_update_from_context_view3d(C);
mode_transferred = true;
}

View File

@ -3183,7 +3183,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
static bool keyframe_jump_poll(bContext *C)
{
/* There is a keyframe jump operator specifically for the Graph Editor. */
return ED_operator_screenactive_norender(C) && ED_operator_graphedit_active(C);
return ED_operator_screenactive_norender(C) && !ED_operator_graphedit_active(C);
}
static void SCREEN_OT_keyframe_jump(wmOperatorType *ot)

View File

@ -507,14 +507,21 @@ static void reassign_loose_edge_verts(const int orig_verts_num,
}
const VertLooseEdges vert_info = calc_vert_loose_edges(
vert_to_edge_map, loose_edges, split_edges, vert);
bool finished = false;
for (const int edge : vert_info.selected) {
const int new_vert = orig_verts_num + new_verts[new_vert_i];
swap_edge_vert(edges[edge], vert, new_vert);
new_vert_i++;
if (new_vert_i == new_verts.size()) {
continue;
finished = true;
break;
}
}
if (finished) {
continue;
}
const int new_vert = orig_verts_num + new_verts[new_vert_i];
for (const int orig_edge : vert_info.unselected) {
swap_edge_vert(edges[orig_edge], vert, new_vert);

View File

@ -102,11 +102,31 @@ static float get_aspect_scaled_extent(const rctf &extent, const UVPackIsland_Par
}
/**
* \return true iff `b` is a preferred layout over `a`, given the packing parameters supplied.
* \return the area of `extent`, factoring in the target aspect ratio.
*/
static float get_aspect_scaled_area(const rctf &extent, const UVPackIsland_Params &params)
{
const float width = BLI_rctf_size_x(&extent);
const float height = BLI_rctf_size_y(&extent);
return (width / params.target_aspect_y) * height;
}
/**
* \return true if `b` is a preferred layout over `a`, given the packing parameters supplied.
*/
static bool is_larger(const rctf &a, const rctf &b, const UVPackIsland_Params &params)
{
return get_aspect_scaled_extent(b, params) < get_aspect_scaled_extent(a, params);
const float extent_a = get_aspect_scaled_extent(a, params);
const float extent_b = get_aspect_scaled_extent(b, params);
/* Equal extent, use smaller area. */
if (compare_ff_relative(extent_a, extent_b, FLT_EPSILON, 64)) {
const float area_a = get_aspect_scaled_area(a, params);
const float area_b = get_aspect_scaled_area(b, params);
return area_b < area_a;
}
return extent_b < extent_a;
}
PackIsland::PackIsland()
@ -1847,8 +1867,10 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
/* At this stage, `extent` contains the optimal/box_pack/xatlas UVs. */
if (all_can_rotate) {
/* Attempt to improve the layout even further by finding the minimal-bounding-square. */
/* If more islands remain to be packed, attempt to improve the layout further by finding the
* minimal-bounding-square. Disabled for other cases as users often prefer to avoid diagonal
* islands. */
if (all_can_rotate && aabbs.size() > slow_aabbs.size()) {
rotate_inside_square(slow_aabbs, islands, params, scale, margin, r_phis, &extent);
}

View File

@ -216,12 +216,12 @@ bool python_script_error_jump(
else {
PyErr_NormalizeException(&exception, &value, (PyObject **)&tb);
for (tb = (PyTracebackObject *)PySys_GetObject("last_traceback");
tb && (PyObject *)tb != Py_None;
tb = tb->tb_next)
for (PyTracebackObject *tb_iter = (PyTracebackObject *)PySys_GetObject("last_traceback");
tb_iter && (PyObject *)tb_iter != Py_None;
tb_iter = tb_iter->tb_next)
{
PyObject *coerce;
const char *tb_filepath = traceback_filepath(tb, &coerce);
const char *tb_filepath = traceback_filepath(tb_iter, &coerce);
const int match = ((BLI_path_cmp(tb_filepath, filepath) == 0) ||
(ELEM(tb_filepath[0], '\\', '/') &&
BLI_path_cmp(tb_filepath + 1, filepath) == 0));
@ -229,7 +229,7 @@ bool python_script_error_jump(
if (match) {
success = true;
*r_lineno = *r_lineno_end = tb->tb_lineno;
*r_lineno = *r_lineno_end = tb_iter->tb_lineno;
/* used to break here, but better find the inner most line */
}
}