Introduce GIMP_PATTERN_MAX_SIZE (10000) and GIMP_PATTERN_MAX_NAME (256)
and validate pattern dimensions and pattern name length against them.
Add GIMP_BRUSH_MAX_NAME and validate that too.
Also make sure that the names are properly terminated, and some
cleanup.
The file formats GBR and PAT contain names which are supposed to be
NUL-terminated within the files. If no such terminating NUL byte
exists, the parsers of GBR and PAT trigger an out of boundary read
during utf-8 conversion.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
It is possible to trigger a heap overflow while opening a malicious
pattern due to integer overflows.
The validation is adopted from plugin-parser. It also takes a proper
cast to gsize to avoid integer overflow in size calculation.
Change gimp_pixbuf_create_buffer() to copy the pixels if a linear
buffer cannot be created. Add functions that convert between
GimpTempBuf and GdkPixbuf. Fix users of gimp_pixbuf_create_buffer()
to make the least possible copies. Patch modified by Mitch.
Fix the places that passed the color by either temp_buf_data_clear()
or memset(), and assign x and y manually, they are going to vanish
completely soon.
2009-01-17 Michael Natterer <mitch@gimp.org>
* all files with a GPL header and all COPYING files:
Change licence to GPLv3 (and to LGPLv3 for libgimp).
Cleaned up some copyright headers and regenerated the parsers in
the ImageMap plugin.
svn path=/trunk/; revision=27913
2006-08-29 Michael Natterer <mitch@gimp.org>
Changed GimpViewable preview rendering to have a context to get
FG/BG/whatever from. Use the context to enable dynamic FG/BG
colors in gradients. Fixes bug #127676 and bug #352214. Addresses
bug #128367 (doesn't fix it because there's no loading/saving and
no GUI yet).
* app/core/core-enums.[ch]: added enum GimpGradientColor to enable
specifying gradient colors in terms of foreground and background.
* app/core/gimpgradient.[ch]: added color_type members to the
GimpGradientSegment struct and honor them in
gimp_gradient_get_color_at(). Added GimpContext parameters to all
functions which finally call get_color_at().
* app/core/gimp-gradients.c: use the new method to implement the
builtin gradients.
* app/core/gimpviewable.[ch]: added GimpContext parameters to all
get_preview() and get_pixbuf() functions.
* app/core/gimpbrush.c
* app/core/gimpbuffer.c
* app/core/gimpdrawable-preview.[ch]
* app/core/gimpgradient.c
* app/core/gimpimage-preview.[ch]
* app/core/gimpimagefile.c
* app/core/gimppalette.c
* app/core/gimppattern.c
* app/core/gimpundo.[ch]
* app/text/gimpfont.c
* app/vectors/gimpvectors-preview.[ch]: changed ::get_preview()
and ::get_pixbuf() implementations accordingly.
* app/core/gimpdrawable-blend.c
* app/core/gimppalette-import.[ch]
* app/dialogs/dialogs-constructors.c
* app/dialogs/palette-import-dialog.c
* app/dialogs/resize-dialog.c
* app/display/gimpdisplayshell-layer-select.c
* app/display/gimpdisplayshell.c
* app/display/gimpnavigationeditor.c
* app/paint/gimppaintoptions.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimptexttool.c
* app/actions/gradient-editor-commands.c
* app/widgets/gimpaction.c
* app/widgets/gimpbrusheditor.[ch]
* app/widgets/gimpbufferview.c
* app/widgets/gimpcellrendererviewable.c
* app/widgets/gimpchanneltreeview.c
* app/widgets/gimpclipboard.c
* app/widgets/gimpcoloreditor.c
* app/widgets/gimpcomponenteditor.c
* app/widgets/gimpcontainerbox.c
* app/widgets/gimpcontainercombobox.c
* app/widgets/gimpcontainereditor.c
* app/widgets/gimpcontainerentry.c
* app/widgets/gimpcontainergridview.c
* app/widgets/gimpcontainertreeview.[ch]
* app/widgets/gimpdataeditor.[ch]
* app/widgets/gimpdevicestatus.c
* app/widgets/gimpdnd.[ch]
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpfiledialog.c
* app/widgets/gimpgradienteditor.[ch]
* app/widgets/gimpgradientselect.c
* app/widgets/gimpitemtreeview.c
* app/widgets/gimplayertreeview.c
* app/widgets/gimppaletteeditor.[ch]
* app/widgets/gimppropwidgets.[ch]
* app/widgets/gimpselectioneditor.c
* app/widgets/gimpthumbbox.[ch]
* app/widgets/gimptoolbox-image-area.c
* app/widgets/gimptoolbox-indicator-area.c
* app/widgets/gimptooloptionseditor.c
* app/widgets/gimpundoeditor.c
* app/widgets/gimpvectorstreeview.c
* app/widgets/gimpview-popup.[ch]
* app/widgets/gimpview.[ch]
* app/widgets/gimpviewablebutton.c
* app/widgets/gimpviewabledialog.c
* app/widgets/gimpviewrenderer.[ch]
* app/widgets/gimpviewrenderer-frame.c
* app/widgets/gimpviewrendererbrush.c
* app/widgets/gimpviewrendererbuffer.c
* app/widgets/gimpviewrendererdrawable.c
* app/widgets/gimpviewrenderergradient.c
* app/widgets/gimpviewrendererimage.c
* tools/pdbgen/pdb/drawable.pdb
* tools/pdbgen/pdb/gradient.pdb
* tools/pdbgen/pdb/gradients.pdb
* tools/pdbgen/pdb/image.pdb: added tons of GimpContext members
and parameters, implement GimpDocked::set_context() in many
widgets. Pass these locally remembered contexts to GimpViewable
functions. Did some minor cleanups on the way. There are still
some minor FIXMEs around where the code uses a NULL context (which
is allowed by the APIs)
* app/pdb/drawable_cmds.c
* app/pdb/gradient_cmds.c
* app/pdb/gradients_cmds.c
* app/pdb/image_cmds.c: regenerated.
2005-12-10 Michael Natterer <mitch@gimp.org>
* app/config/*.c
* app/core/*.c
* app/display/*.c
* app/text/*.c
* app/vectors/*.c: port to G_DEFINE_TYPE() and friends. Some related
core reordering and cleanup.
2005-10-10 Michael Natterer <mitch@gimp.org>
* app/core/gimpviewable.c (gimp_viewable_get_description): set the
"tooltip" return value to NULL before calling the virtual function.
* app/core/gimpbrush.c
* app/core/gimpbuffer.c
* app/core/gimpchannel.c
* app/core/gimplayer.c
* app/core/gimppaintinfo.c
* app/core/gimppalette.c
* app/core/gimppattern.c
* app/core/gimptoolinfo.c (get_description): don't do it here.
* app/core/gimpbuffer.c
* app/core/gimppaintinfo.c: untabbify, cleanup.
* app/core/gimpobject.c: emit "notify::name" whenerver the name
changes, clenup.
2005-06-08 Sven Neumann <sven@gimp.org>
Removed "stingy-memory-use" all over the place. This feature was
really not that useful anymore. The GUI for the preference option
was already removed for GIMP 2.2. Fixes bug #306617.
* app/config/gimpbaseconfig.[ch]: set IGNORE flag on
"stingy-memory-use".
* app/config/gimpcoreconfig.h: added a comment that the
font_path_writable variable is unused.
* app/base/temp-buf.[ch]: removed code that used to deal with
swapping temp-bufs to disk.
* app/base/base.c: made base_config a static variable.
* app/core/gimpdata.[ch]
* app/core/gimpdatafactory.[ch]: removed stingy_memory_use
parameter from data construction methods.
* app/core/gimp-gradients.c
* app/core/gimpbrush-load.[ch]
* app/core/gimpbrush.[ch]
* app/core/gimpbrushgenerated.[ch]
* app/core/gimpbrushpipe.[ch]
* app/core/gimpcontext.c
* app/core/gimpgradient-load.[ch]
* app/core/gimpgradient.[ch]
* app/core/gimppalette-import.c
* app/core/gimppalette.[ch]
* app/core/gimppattern.[ch]: changed accordingly.
2005-05-26 Sven Neumann <sven@gimp.org>
* app/core/gimpdata.[ch]: added MIME type as a construct property
to GimpData.
* app/core/gimpbrush-load.c
* app/core/gimpbrushgenerated.c
* app/core/gimpbrushpipe.c
* app/core/gimpgradient-load.c
* app/core/gimppalette.c
* app/core/gimppattern.c: set the MIME type when loading a data
object from file. MIME types needs review and GimpPalette isn't
quite done yet...
* app/core/gimpdashpattern.c: cosmetics.
2005-05-25 Michael Natterer <mitch@gimp.org>
* app/core/gimpviewable.[ch]: added virtual function
GimpViewable::get_size() and public API gimp_viewable_get_size()
which return width and height and a boolean indicating if the
viewable has a size at all.
Added default implementation of GimpViewable::get_popup_size()
using the new get_size() API.
* app/core/gimpbrush.c
* app/core/gimpbuffer.c
* app/core/gimpdrawable.c
* app/core/gimpimage.c
* app/core/gimppattern.c: implement GimpViewable::get_size().
* app/core/gimpbrush.c
* app/core/gimppattern.c: removed GimpViewable::get_popup_size()
implementations, the default one is good enough.
* app/core/gimpbrushpipe.c (gimp_brush_pipe_get_popup_size):
redirect to gimp_viewable_get_size() instead of duplicating its
return values.
* app/widgets/gimpcontainertreeview.c
* app/widgets/gimpview.c: allow pixbuf dragging out of any
viewable that has a size.
* app/widgets/gimpdrawabletreeview.c: removed pixbuf dragging code
here.
* app/widgets/gimpdnd.c: set gimp busy around encoding/decoding
pixbufs into/from GtkSelectionData, because it can be a time
consuming operation.
2004-07-26 Michael Natterer <mitch@gimp.org>
* app/core/gimpdatafactory.h: added "gboolean writable" to the
GimpDataFactoryLoaderEntry struct. Return a GList* instead of
GimpData* from GimpDataLoadFunc so it's possible to load more than
one data object from one file.
* app/core/gimpdatafactory.c (gimp_data_factory_load_data):
changed accordingly: add all items of the returned lists to the
data factory. Make the data object writable only if it's in the
writable path *and* its loader entry says it's a writable format
*and* the returned list contains exactly one element.
* app/core/gimp.c (gimp_real_initialize): declare all loader
entries as writable where we have code to read and write exactly
one object per file; all others are not writable.
* app/core/gimpbrush.[ch]
* app/core/gimpbrushgenerated.[ch]
* app/core/gimpbrushpipe.[ch]
* app/core/gimpgradient-load.[ch]
* app/core/gimppalette.[ch]
* app/core/gimppattern.[ch] (all load functions): return a list
containing the loaded object instead of the object itself.
2004-06-03 Sven Neumann <sven@gimp.org>
* app/core/gimpdatafactory.c (gimp_data_factory_load_data):
removed commented-out message.
* app/core/gimppattern.[ch]: fixed handling of errors and PNG
comments in new pattern loader. Renamed functions for consistency
with other data loaders.
* app/core/gimp.c: changed accordingly.
2004-06-03 Dave Neary <bolsh@gimp.org>
* app/core/gimp.c:
* app/core/gimpdatafactory.c:
* app/core/gimppattern.[ch]: Add support for GdkPixbuf patterns,
so now all of png, jpex, pnm, xbm, bmp, gif, ico, pcx, ras, tga,
xpm and tiff can be used for patterns.
2004-02-13 Michael Natterer <mitch@gimp.org>
Fixed GimpData's default "writable" and "deletable" behaviour:
* app/core/gimpdata.c (gimp_data_init): default to writable and
deletable == TRUE (something that has no filename was never loaded
from disk and can't be undeletable or read-only).
Fixes bug #134274.
* app/core/gimpdata.[ch]: added new function
gimp_data_make_internal() which frees the filename and sets the
data's flags accordingly.
* app/core/gimp-gradients.c (gimp_gradients_add_gradient)
* app/core/gimpbrush.c (gimp_brush_get_standard)
* app/core/gimpgradient.c (gimp_gradient_get_standard)
* app/core/gimppalette.c (gimp_palette_get_standard)
* app/core/gimppattern.c (gimp_pattern_get_standard): use the
new function for internal data objects.
* app/core/gimpdata.c (gimp_data_save, gimp_data_delete_from_disk)
* app/core/gimpdatafactory.c (gimp_data_factory_save_single):
bail out with g_return_if_fail() is the data is not writable
or deletable.
* app/widgets/gimpdataeditor.c
* app/widgets/gimpdatafactoryview.c: changed accordingly.
2004-01-29 Michael Natterer <mitch@gimp.org>
GimpData code review:
* app/core/gimpdata.c (gimp_data_init): default to
writable = FALSE and dirty = TRUE.
* app/core/gimpbrushgenerated.[ch]: added "const gchar *name" to
gimp_brush_generated_new().
* app/core/gimpbrush.c
* app/core/gimpbrushgenerated.c
* app/core/gimpbrushpipe.c
* app/core/gimpgradient.c
* app/core/gimppalette.c
* app/core/gimppattern.c: set all standard datas to clean and
internal, check for g_path_is_absolute() in all load functions,
pass the data's name as construct property to g_object_new()
instead of calling gimp_object_set_name() after creation, fixed
some UTF-8 handling, spacing, indentation, coding style, general
cleanup.
2004-01-28 Michael Natterer <mitch@gimp.org>
Added infrastructure to make sure we don't write to the global
brush, pattern etc. directories. Needed to make this configurable
because we can't rely on the global directories being read-only,
having certain names or being otherwise detectable at runtime in a
sane way. Fixes bug #132214.
* libgimpbase/gimpdatafiles.[ch]: added "const gchar *dirname" to
the GimpDataFileData struct so callbacks don't need to call
g_path_get_dirname() for each file.
* libgimpwidgets/gimpfileentry.c: made it work with non UTF-8
encoded filenames.
* libgimpwidgets/gimppatheditor.[ch]: ditto. Added GUI and API for
setting/getting a second "writable_path". The widget makes sure
that the writable_path is always a subset of the path.
* app/config/gimpconfig-utils.[ch]: added new function
gimp_config_build_writable_path().
* app/config/gimpcoreconfig.[ch]: added separate properties for
the writable brush, pattern, gradient, palette and font paths.
* app/config/gimprc-blurbs.h: added (still empty) blurbs for the
new properties.
* app/core/gimpdata.[ch] (gimp_data_set_filename): added parameter
"gboolean writable". Set data->writable to FALSE by default. If
"writable" is passed as TRUE, still check if we can write to the
file before setting data->writable to TRUE.
(gimp_data_create_filename): changed "data_path" parameter to
"dest_dir" and assume dest_dir is writable.
(gimp_data_duplicate): set data->dirty to TRUE to make sure
duplicated things will be saved.
* app/core/gimpbrush.c
* app/core/gimpbrushgenerated.c
* app/core/gimpbrushpipe.c
* app/core/gimpgradient.c
* app/core/gimppalette.c
* app/core/gimppattern.c: don't set the data's filename and don't
touch data->dirty in the _load() functions because that's done by
the data factory now. Don't touch data->dirty in the _duplicate()
functions because that's done by gimp_data_duplicate() itself now.
* app/core/gimpdatafactory.[ch] (gimp_data_factory_new): added
"writable_property_name" and remember it.
Added utility function gimp_data_factory_get_save_dir() which
determines the directory to save new datas to.
Added public function gimp_data_factory_data_save_single() which
saves a single data object.
Make sure new things get saved to the first writable directory
as specified in preferences.
* app/core/gimp.c (gimp_real_initialize): pass the writable_paths'
property names to gimp_data_factory_new().
* app/widgets/gimpdataeditor.c (gimp_data_editor_save_dirty): use
gimp_data_factory_data_save_single() instead of implementing
saving here.
* app/widgets/gimppropwidgets.[ch] (gimp_prop_path_editor_new):
added "const gchar *writable_property_name" parameter (can be
NULL).
Added the needed callbacks to handle the writable_path and made
the path_editor and file_entry code aware of non UTF-8 filename
encodings. Some general cleanup.
* app/gui/preferences-dialog.c: changed accordingly.
2004-01-19 Sven Neumann <sven@gimp.org>
* app/*/*.c: include "libgimpbase/gimpbase.h" where needed; removed
now unnecessary inclusions of "file/file-utils.h".
2004-01-19 Sven Neumann <sven@gimp.org>
* app/file/file-utils.[ch]: removed file_utils_filename_to_utf8() ...
* libgimpbase/gimputils.[ch]: ... and added it here as
gimp_filename_to_utf8(). Added some docs that promise less than
the current implementation holds so that we can change the
implementation later.
* app/*/*.c: use gimp_filename_to_utf8() where
file_utils_filenames_to_utf8() has been used before.
* libgimpbase/gimpbase.def: changed accordingly.
* configure.in: reset GIMP_INTERFACE_AGE.
2004-01-14 Tor Lillqvist <tml@iki.fi>
* app/file/file-utils.[ch]: Add new function
file_utils_filename_to_utf8(), which is to be used when converting
file names (which are kept in the on-disk encoding) to UTF-8 for
passing to GTK, or to g_print() etc.
* app/*/*.c: Call file_utils_filename_to_utf8(). Should fix most
of the warnings generated by non-UTF8 pathnames. See #130118.
* libgimpbase/gimpenv.b: Document that gimp_directory() etc return
strings in the on-disk encoding.
* libgimpmodule/gimpmodule.c: Convert filenames to UTF-8 (using
g_filename_to_utf8()) before passing to g_print().
2003-11-17 Sven Neumann <sven@gimp.org>
* app/core/gimpviewable.[ch]: removed the unused GimpViewable
parameter from gimp_viewable_calc_preview_size().
* app/core/gimpbuffer.c
* app/core/gimpimage-preview.c
* app/core/gimpimagefile.c
* app/core/gimpitem-preview.c
* app/core/gimpundo.c
* app/widgets/gimppreview.c
* app/widgets/gimppreviewrendererdrawable.c
* app/widgets/gimppreviewrendererimage.c: changed accordingly.
* app/widgets/gimppreviewrenderer.[ch]: store the viewable_type in
the preview renderer and use its default stock_id if no viewable
is set.
* app/core/gimpbrush.c
* app/core/gimpbuffer.c
* app/core/gimpgradient.c
* app/core/gimppalette.c
* app/core/gimppattern.c
* app/core/gimpundo.c: set a default stock_id.
2003-10-16 Michael Natterer <mitch@gimp.org>
* libgimpbase/gimputils.[ch]: new function which takes any string
and returns UTF-8 (it returns "(invalid UTF-8 string)" if all
conversion attempts fail).
* app/core/gimpbrush.c
* app/core/gimpgradient.c
* app/core/gimppalette.c
* app/core/gimppattern.c
* app/xcf/xcf-read.c: use it. Fixes bug #79897.