As reported by Coverity, in the (rare) case where the wstrlcat would fail
the array for the result would not be freed before returning.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As reported by Coverity, the function 'WMGetTextFieldText' allocates memory
to generate the result string, so it has to be freed.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by Coverity, there is a small check for NULL pointer when
handling triple-click selection in a WMText, however this check is only
partially implemented so the code would crash later anyway.
This patch implement an appropriate skip to avoid crash, and includes a
log message to help debug if the case happens.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by Coverity, despite apparent checks the function would fail if
trying to set a NULL title. Instead of trying to do over-complicated things
we just ignore (with a warning if NDEBUG is not set) the case. If user
wants an empty title, the correct way is to provide "" as we're not able to
remove a title.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by coverity, the case 'index < 0' cannot be true because it was
already earlier and handled with an early return.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The information about the File, Line and Function name that were included
in the assertion message are already present from the 'wwarning' macro, so
it is not necessary to include them in the macro's message.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
In many places of the code these functions are counting on the "return"
effect of these macros to gracefully handle incorrect arguments. So, when
debug is not enabled, if it is okay to not display a message it is however
not good to completely skip the check and skip the early return.
This patch changes the macro to always perform the check and return to
avoid crashes, displaying a message only when NDEBUG is not set.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As reported by coverity, calling 'wexpandpath' with a path that contains
either '$()', '$(\0' or '$\0' would cause an undefined behaviour because
the 'buffer2' would be uninitialised.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by Coverity (#50226), the function getenv can return unreliable
data, so if a sensitive application makes uses of the function 'wgethomedir'
or 'wusergnusteppath' we'd better use the GNU function secure_getenv which
ignore environment variable when used in a known critical cases.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by Coverity, the type used to calculate the size to allocate was
not the right one. It now gets the compiler to deduce it from the variable
for which the memory is allocated.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by Coverity, the return value of the function 'wdefaultspathfordomain'
cannot be NULL, so it is not necessary to check for that.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by Coverity, the macro RETRY does not behave as expected, as it
assumes that errno is cleared on successful 'fopen' call which is not the
case.
This patch removes the uses of the macro RETRY:
- fopen: with the appropriate check
- fread/fwrite: nothing because they do not set errno
- fclose: nothing because retrying is not recommended
and took the opportunity to add a little bit more information in the error
messages.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The function wrealloc never fails, and allocates enough storage to store
the resulting string, so it is useless to check if strcat failed.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by Coverity (#50074), despite the expected behaviour that
'wmalloc' should never return NULL, it may still happen if an abort handler
set by user (with wsetabort) does not call exit() as expected. In such
case we call exit ourself to be sure not to return NULL.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by Coverity, if the user does not a an entry in the password
file then the function would assume its home path to be "/" but still
continue and later try to check for user->pw_dir which would dereference
the NULL pointer.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This allow compiler to raise a warning in case a new value would be added
to the enum; it also change order in the check so that WMGetButtonSelected
will be called only once, only for the case of interest.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The RGB panel of the WINGs color panel lists the red, green, and blue values as
base 10 numbers. However, hexadecimal numbers are very common when dealing with
RGB colors. This patch adds two radio buttons at the bottom of the RGB panel
to allow users to choose their preferred number system.
For version 2 of the patch:
Based on Cristophe's suggestions regarding the new decimal/hexadecimal RGB color
feature introduced in commit 83d8ad6, this patch changes rgbState from an int
to an enum, converts some if statements to switches, and changes from atoi to
strtol for the base 10 string conversion.
In addition, the "hexadecimal" text was too wide for the default size of its
radio button for some fonts, so both radio buttons are now resized to fit the
width of the panel.
In commit b4cb488, wprogressindicator.c was removed. It was restored in commit
d435ea7, but the corresponding declarations in WINGs/WINGs.h were not. This
patch fixes this oversight.
In the function 'wdefaultspathfordomain' there was a check to make sure the
generated path would fit in the allocated area, but this allocated area is
sized precisely to fit the path, so it cannot fail.
In the function 'getCurrentFileName' there were checks to make sure the
generated result string would fit in the allocated area, but this allocated
area is sized precisely to fit the path, so it cannot fail.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The function would not behave correctly if called twice, and the
library may re-use de-allocated pointers if calling WINGs functions
after calling this function.
The goal is for our library to behave as cleanly as possible, so
that users may have a clearer hint in case of misuse on their side
to debug the problem.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by the commpiler, the variable 'syslog_prefix' is not used
in the code, so it is removed.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Due to some old and recent patches, the msgid used for translating the
error messages were not in line with the source code, now they are.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Recent patches has introduced the ability to exit cleanly from the WINGs
library, but this introduced some side effects because a function is
registered with 'atexit' to save user config on exit, which may not work
anymore because WMReleaseApplication frees some stuff needed for that task.
This patch handles this so that both method works, in case user of the lib
would forget to call the clean exit function.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
A number of files have been added to the Window Maker source tree but are not
included in the tarball produced by "make dist" because they have not been added
to EXTRA_DIST in the appropriate Makefile.am. They are:
- Dutch translation files (commit afc90)
- email-clients.txt (commit 385db)
- WPrefs source files removed from WPrefs_SOURCES (commit 21dfd)
This patch adds these missing files.
Currently, there is no WUtil.pc file so that WINGs developers can use
pkg-config to compile programs using the WINGs utility library. This patch
fixes this, and such a file is created by make, just like WINGs.pc and
wrlib.pc.
In addition, the WUtil.pc file has been added to .gitignore and included in
the debian libwings-dev package.
The original code would not provide correctly sized images in some cases
of ratios on the original image and on the requested size.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
WUtil's file misc.c was including the private header for WINGs, where it
should have been using WUtil's public header instead.
Took opportunity to include the appropriate copyright header.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This patch is used to add support for syslog messaging implemented in
WINGs lib directly, so available from the lib itself and wmaker too.
I believe it will in a first time help to get some logging info
centralized in one point, and in a second time maybe add some info
level messages like wmaker is starting, stopping, restarting and else.
For now, it's built by default when the syslog support is found, maybe
we could also disable it by default.
Because the existing nl locale files are ancient and obsolete,
the user interface stays mainly in English with hardly Dutch text
showing up.
This is a complete translation in 6 parts from scratch, using the
current (pl)menus and Makefile generated .pot files. These files
provide a very good, and thoroughly checked user interface in the
Dutch language.
Adding me as a maintainer in related README files; removing previous
maintainer (e-mail bounced).
Removing unnecessary executable bit from pt.po on the fly.
Although this is a modification of the public API, this patch does not
change the binary interface, and the attribute does not add a constraint
on the parameter for the caller so we do not break the source compatibility
either.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The usual way to define a macro in is to name macro with 'USE_xxx' when
they are used to enable a feature 'xxx'
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>