WINGs: fix WMPathForResourceOfType to check for all the paths it claims to check

The "documentation" of the function claims to check for the resource in a
number of path, but factually if the application did provide its argument
list when creating the WINGs App structure (which is likely) then the
search would stop before checking all paths.

The code now continues as expectable if the resource was not found in the
path. Took opportunity to avoid a temporary allocation that participated in
memory fragmentation.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
WINGs: to not allocate memory for a short lived array (Coverity #50136)

As pointed by Coverity, the array created to temporary store the list of
Atoms used in the function 'requestHandler' was leaked.

Because this array is very short lived, there is no need to allocate memory
for this, it just participates in memory fragmentation. Instead, we use now
memory on the stack which is more efficient.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
WINGs: fix possible problems due to sign extension when setting Icon (Coverity #50202)

As pointed by Coverity, there might be some problems due to sign extension
when performing the shifts and ors operations when converting the RImage to
the format expected for the WM_ICON property.

This patch try to improve things by using as much as possible unsigned
types and by using explicit types conversion instead of counting on the
wrong implicit type conversion done by the language.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
wmaker: add check for null pointer in wAppIconCreateForDock (Coverity #50053)

As pointed by Coverity, there is in the same procedure a check for null
pointer before use, and later a direct use without check.

In most case, the pointer is not null, but it one case it is hard to be
sure that the pointer cannot be null, so it's safer to just add a check
there also.

Took opportunity to swap the order of the arguments in the if, because if
the config flag is false it is not necessary to spend time on doing the
more expensive strcmp.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>

THIS PATCH WAS MODIFIED BY Rodolfo García Peñas (kix) because cannot be
applied in the awmaker git without changes. This patch is based in the
original patch created by Christophe CURIS <christophe.curis@free.fr>.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
wmaker: change strcpy to the version with size check (Coverity #50217)

As pointed by Coverity, there were a number of copies done into fixed-size
buffer, it's safer to use the function that sets a limit on the size to
avoid a crash.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>

THIS PATCH WAS MODIFIED BY Rodolfo García Peñas (kix) because cannot be
applied in the awmaker git without changes. This patch is based in the
original patch created by Christophe CURIS <christophe.curis@free.fr>.
wmaker: fix possible buffer overrun with filename for Icon Chooser (Coverity #50218)

As pointed by Coverity, there is a possible (yet improbable) buffer overrun
when building the list of files to be used in the Icon Chooser dialog.

Better safe than sorry, let's use the safer function to build the complete
name, and add a little message to the user in case of problem so at least
he can know something was not right.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
wmaker: replaced temporary allocation by local storage for error message

In case of problem with a directory when building the list of files for the
Icon Chooser dialog, an error message was generated using a temporary
allocated buffer. This is not really good for memory fragmentation, so this
patch re-uses the local buffer which will be enough for all reasonable
cases.

Took opportunity to make message less prone to translation difficulties,
and include more information about the problem to the user so he may know
what went wrong.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>

THIS PATCH WAS MODIFIED BY Rodolfo García Peñas (kix) because cannot be
applied in the awmaker git without changes. This patch is based in the
original patch created by Christophe CURIS <christophe.curis@free.fr>.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
wmaker: remove intermediate strcpy in updateWorkspaceMenu (Coverity #50213)

Coverity warned because the 2 strcpy may overflow the target buffer (the
code relies on a constant for the max allowed workspace name length).

As in both cases the temporary copy is not useful because the temp copy
will be strdup'd just after, this patch removes the temporary buffer and
uses directly the string.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>

THIS PATCH WAS MODIFIED BY Rodolfo García Peñas (kix) because cannot be
applied in the awmaker git without changes. This patch is based in the
original patch created by Christophe CURIS <christophe.curis@free.fr>.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
wmaker: do not store return value that we don't use (Coverity #50252)

As pointed by Coverity, we store a value into the variable 'entry' but we
never use it later, although we re-use the variable.

For the maintainability of the code, it is not really good as it could
mislead into thinking the value could be used, so this patch removes the
assignation.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>

THIS PATCH WAS MODIFIED BY Rodolfo García Peñas (kix) because cannot be
applied in the awmaker git without changes. This patch is based in the
original patch created by Christophe CURIS <christophe.curis@free.fr>.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
wmaker: fix signedness of variable (Coverity #50082, #50222)

Coverity complain that there can be security issues because the variable
'i' is being modified using untrusted data (coming from a file). This is
probably pessimistic, because in the present case we're talking with the
kernel.

Using the correct signedness for the variable should however keep us safe,
and (I hope) make Coverity happy.

Took opportunity to include an error message in case of read problem
because it can help to debug.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
wmaker: removed variable 'done' to prepare return status in 'wNETWMProcessClientMessage'

Using a variable to store the return value that will be used later is not a
good idea, because it forces to track everywhere in the function when
needing to work on the function.

This patch removes the variables and places explicit return if each case,
so on first look it is clear where the code stops.

It also fixes a bug where the function would handle an event but still
returns False (meaning the event was not treated), whose root cause was
coming from the complexity brought by the variable.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>

THIS PATCH WAS MODIFIED BY Rodolfo García Peñas (kix) because cannot be
applied in the awmaker git without changes. This patch is based in the
original patch created by Christophe CURIS <christophe.curis@free.fr>.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
wmaker: remove unnecessary check in acceptXDND (Coverity #72817)

As pointed by Coverity, if dock is still null at this point then the
function will return via the previous check, because it is not possible to
have icon_pos >= 0 if dock is null.

This patch removes the check because it complicate the code which is not
recommended for maintainability.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>

THIS PATCH WAS MODIFIED BY Rodolfo García Peñas (kix) because cannot be
applied in the awmaker git without changes. This patch is based in the
original patch created by Christophe CURIS <christophe.curis@free.fr>.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
WPrefs: fix memory leak when storing the list of colors in Appearence panel

The name of the color is stored in a newly created PLString which leaks.
This is due to the fact that they are created with a refCount of 1, then
the PLArray in which they are placed increments that count, so at list
destruction the count would return to 1 instead of 0, meaning the
PLString won't be freed.

This patch properly calls  WMReleasePropList after addition to the list, so
that the count goes back to 1, which means it will be automatically freed
when the PLArray will be released.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
WPrefs: fix memory leaks on temporary colours to draw icon's title in Appearence preview (Coverity #72808, #72810)

Two WMColor were created to draw the background for the title on icons for
iconified windows, in the Appearance panel. As pointed by Coverity, these
colors were not released after use, which this patch fixes.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
util: return from 'findCopyFile' if the source file could not be found (Coverity #50075)

As pointed by Coverity, the function handles the case where the file to be
copied is not found by properly warning the user and the deleting the
currently built theme directory, but then it continued executing the file
copy that would crash on the null pointer.

This patch just adds the missing return that will avoid the crash.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
util: use wfree instead of free for consistency

The memory was allocated with wmalloc, so for consistency it should be
freed using wfree. This could be a problem if the user compiled with
support for Boehm GC, or if we later decide to add support for other malloc
libraries.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>