[Bf-committers] bpy.Image memoryview problems

Theo de Ridder theo.de.ridder at planet.nl
Wed May 5 09:35:55 CEST 2010


On 5 mei 2010, at 07:53, Campbell wrote:

> indeed it seems there is no way to get a PyCapsule into ctypes.
> Since this was the purpose, as_pointer() could return an 'int' which
> ctypes can convert into a pointer.
> 
> as for security, there are probably easier ways to exploit blender
> then getting a pointer to an image and somehow replacing parts of it
> with machine code???.
> 
> struct.as_pointer() could be rewritten in ctypes alone by getting the
> PyObject pointer the the pointer to the ID from that (which always has
> the same offset), in fact even without any api access, a developer
> with ctypes can write into any part of blenders memory they like.

agreed, in fact I don't like the as_pointer and ctypes approach at all, but
do prefer a clean py_buffer interface to certain types of contiguous
memory data like images and keybuffers; for security it is then good 
enough to have write access to such buffers without being able to change their
sizes; it seems there is some reluctance towards py_buffers, but
my reason for wanting them is that I found a few years
ago enormous benefits in performance and codesize by wrapping
such buffers in numpy (and now I am also looking at openCV
for realtime camera input tracking); my personal opinion is still that
the relevance of numpy is underestimated in the Blender community
for highlevel and fast transformations of huge n-dimensional matrices of colors
and vertices without looping (with getters and setters) at Python level;
but I am not in a hurry with this, numpy2.0 (for python3.x) will not be there
before the 2e half of this year.

~Theo




More information about the Bf-committers mailing list