Commit Graph

16 Commits

Author SHA1 Message Date
Lukas Oberhuber e6d0766821 Remove another error message 2021-10-20 00:29:37 +01:00
Lukas Oberhuber 219d9b4e1a Reduces noisy errors
Also avoids code that can't run properly on a Mac anyway.
2021-10-09 17:32:58 +01:00
Lukas Oberhuber f87ec4bcfe libgimpbase: GError set twice in gimpreloc.c
This patch fixes a double free error due to a pointer being freed and 
then not nulled out.
It appears this is corrupting memory on MacOS as the `/proc` file system 
is not available and therefore multiple errors are returned.

Fixes:

(process:54873): GLib-WARNING **: 23:09:25.976: GError set over the top of
a previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL
before it's set.
The overwriting error message was: Error opening file /proc/self/maps: No
such file or directory
_br_find_exe: (NULL)gimp-console(54873,0x100957e00) malloc: *** error for
object 0x103f09e80: pointer being freed was not allocated
gimp-console(54873,0x100957e00) malloc: *** set a breakpoint in
malloc_error_break to debug
2021-10-03 00:29:15 +00:00
Jehan 362e00f209 libgimpbase: get rid of one more PATH_MAX.
See commit 47fbfc2f0e for the reason.
2021-03-20 21:15:15 +01:00
Jehan 8586f16f31 libgimpbase: fix _gimp_reloc_init_lib().
While testing the relocatable code paths, I realized that
_br_find_exe_for_symbol() was always returning NULL. The reason is that
our code looking at /proc/self/maps was expecting that the searched
pointer would be in a "r-xp" memory region. On my machine though, it was
in a "r--p" region.
Maybe in some cases or some older kernel, the "r-xp" permission is/was
right, I have no idea, so now let's just not make any assumption on the
region's permission, where we expect to find our static string, i.e.
let's not do any test on the region permission anymore.
2021-03-20 20:42:29 +01:00
Jehan 47fbfc2f0e libgimpbase: do not assume PATH_MAX to be the actual max size of paths.
Even though it is set by Linux's limits.h and apparently by other OSes
too, it seems this macro is mostly bogus. On many systems, the actual
allowed max size of paths is much higher.
On Hurd, they don't even define the macro as there is no upper limit.
See MR !424.

This commit replaces two usages of PATH_MAX:
- readlink() by g_file_read_link(). I checked the GLib implementation
  and could confirm it will do the proper thing, which is progressively
  incrementing their buffer allocation in a loop until the buffer is big
  enough to contain the symbolic link contents. Hence no need to rely on
  a bogus macro which is not the actual max.
- fgets() by g_data_input_stream_read_line() which also dynamically
  allocates the returned buffer, and also properly removes the newline
  and adds a NUL byte (hence simpler code).

Additionally I loop through the lines of /proc/self/maps until I find
the first "r-xp" pathname. Indeed the current code was assuming that the
first line was always right. Yet on my OS at least, the first line was
GIMP executable with "r--p" permission, hence the test would fail. The
second line had the right permission. So let's assume that we want the
first executable path, looping through each line.
2021-03-20 18:52:40 +01:00
Michael Natterer b007269729 Use g_strlcpy() instead of strncpy() everywhere
except where I didn't understand the code after 10 seconds of
looking..
2019-08-14 23:52:38 +02:00
Jehan 757b8bba7d libgimpbase: style cleanup of gimpreloc.c
No code change, only indentation fixed and opening braces on newline, as
per our style guidelines.
2019-02-05 15:00:44 +01:00
Jehan 4d84c1d7ee app, libgimpbase: --enable-relocatable-bundle replaces --enable-binreloc
Older --enable-binreloc configure option had basically the same purpose
as the newer --enable-relocatable-bundle, though the old binreloc was
only used for gimpenv.c code.
As a consequence, commit 10ce702188 was still not working fine since
gimp_installation_directory_file() also need binreloc enabled (to be
actually relocatable).

Let's get rid of this whole mess, by implying we want binreloc code to
be used when --enable-relocatable-bundle is ON. We don't need the
m4macros anymore, since AM_BINRELOC was basically just checking that
`/proc/self/maps` was present. But anyway being present at compile time
does not mean it will be at runtime (nor the opposite). So this test is
not that useful. The binreloc code will anyway fallback gracefully to
the non-binreloc code (i.e. trying to use build-time install paths) if
the procfs is lacking at runtime.
2019-02-05 14:50:31 +01:00
Rickard 5ec413a5e8 Bug 729326 - Errors found using a static code analysis program cppcheck
Fixed some memory and file leaks. And removed some code and variables
that are not used.
2014-05-05 10:34:08 +02:00
Michael Natterer b7361669e8 libgimpbase: clean up the linux relocation code
by removing all but the toplevel prefix getter from gimpreloc.c It was
1) confusing 2) sometimes trying to subsitute the runtime prefix twice
and 3) sometimes ignoring configure-given directories within the
configure-prefix. This should all be fixed now, and done in one less
place.
2013-01-27 22:26:29 +01:00
Ville Skyttä 6b0d1038cc Bug 692641 - Various spelling fixes 2013-01-27 18:59:02 +01:00
Michael Natterer 8fd8f8ffc0 made the error_message variable const.
2008-09-04  Michael Natterer  <mitch@gimp.org>

	* libgimpbase/gimpreloc.c (set_gerror): made the error_message
	variable const.


svn path=/trunk/; revision=26856
2008-09-04 11:25:31 +00:00
Sven Neumann 493cd140f8 libgimpbase/Makefile.am libgimpbase/libgimpbase-docs.sgml do not generate
2005-12-14  Sven Neumann  <sven@gimp.org>

	* libgimpbase/Makefile.am
	* libgimpbase/libgimpbase-docs.sgml
	* libgimpbase/libgimpbase-sections.txt: do not generate API docs
	for the private wire protocol API.

	* libgimp/libgimp-sections.txt: added new path API.

	* libgimpbase/tmpl/gimpprotocol.sgml
	* libgimpbase/tmpl/gimpwire.sgml: removed from CVS.

	* libgimp/tmpl/gimppaths.sgml
	* libgimpbase/tmpl/gimpenv.sgml: regenerated.
2005-12-14 13:36:12 +00:00
Sven Neumann 6f47447334 minor cleanups.
2005-11-16  Sven Neumann  <sven@gimp.org>

	* libgimpbase/gimpreloc.c: minor cleanups.
2005-11-16 12:03:36 +00:00
Sven Neumann 39e866d9c0 Added support for binary relocation by means of binreloc, largely based on
2005-11-06  Sven Neumann  <sven@gimp.org>

	Added support for binary relocation by means of binreloc, largely
	based on a patch by Hongli Lai:

	* m4macros/Makefile.am
	* m4macros/binreloc.m4: new file providing a macro to check for
	binreloc support.

	* acinclude.m4
	* configure.in: use the macro.

	* libgimpbase/Makefile.am
	* libgimpbase/gimpreloc.[ch]: new files providing binreloc support
	on Linux.

	* libgimpbase/gimpenv.[ch]: use binreloc, provide a function to
	initialize the environment machinery.

	* libgimpbase/gimpbase.def: updated.

	* app/Makefile.am: fiddle with the LDFLAGS for binreloc.

	* app/main.c (main): gimp_env_init(FALSE).

	* libgimp/gimp.c (gimp_main): gimp_env_init(TRUE).
2005-11-06 01:06:41 +00:00