1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 04:20:27 +01:00
Commit Graph

33 Commits

Author SHA1 Message Date
Christophe CURIS
6ef343ed87 WUtil: fix improper use of de-allocated variable (Coverity #109618)
As pointed by Coverity, the variable 'path_dst' was first free'd, then it
was used in the 'unlink' function.

This patch fixes the call order to de-allocate the string only when it is
no more needed.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2015-04-25 07:53:06 -04:00
Christophe CURIS
155e1f1fe1 WUtil: rewrote wcopy_file for better error handling and to fix Coverity #50234
The original code used the libc "fopen" kind of operation, which are handy
when manipulating text files, but:
 - bring an overhead for binary files that we don't need here;
 - does not provide the mechanisms for safe error handling and special cases

As Coverity reported a Time-of-Check/Time-of-Use type of security issue,
took the opportunity to fix it and increased the size of the buffer used
for data to allow better use of modern disk performances.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
2014-11-23 22:42:18 +00:00
Christophe CURIS
c5f103984a WUtil: fix undefined behaviour with $VARS in wexpandpath (Coverity #50244)
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>
2014-05-18 23:00:16 +01:00
Christophe CURIS
a72c166b6e WUtil: make use of secure_getenv if the function is available
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>
2014-05-18 23:00:16 +01:00
Christophe CURIS
8f9b843990 WUtil: fixed possible problem in wcopy_file (Coverity #50141)
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>
2014-05-18 23:00:16 +01:00
Christophe CURIS
978cb1f154 WUtil: fix posible crash in 'wgethomedir' (Coverity #50070)
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>
2014-05-18 23:00:16 +01:00
Christophe CURIS
3c2fc82b6e WUtil: Avoid memory leak and misbehaviour on internal function 'getuserhomedir'
If the function was called more than once with different usernames
it would always return the path for the user on the first call,
which is not what would be expected.

Furthermore, if the function succeeds it allocated memory to save
this path but it was never freed.

The good thing is that the use case for this function is so rare
that it is improbable it was ever called, which explains why it
was never seen.

The new code always behaves as expected, and does not allocate
memory anymore to avoid wasting time and memory for such small
things, which is acceptable because this function is local.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
2013-06-09 16:51:16 +01:00
Christophe CURIS
ea9d3e643f WUtil: Added 'const' attribute to parameters for file related API
As a side note, in 'wfindfileinlist' the first argument should be:
  const char * const *path_list

However, due to limited support for const in plain C, that would
introduce warnings in user code. For compatibility issues, this
was not implemented.
2013-05-04 16:16:18 +01:00
Andreas Bierfert
085224973a Fix incorrect FSF address 2013-01-07 21:19:40 +00:00
Carlos R. Mafra
e1453087f5 WINGs: Rename copy_file() to wcopy_file()
...in order to avoid clashes that happen during compilation of
wmakerconf.

This is a new function in WINGs, so renaming it at this point is
not a big deal.

Thanks to Rodolfo GarcĂ­a for the heads up.
2012-01-31 12:23:54 +00:00
Carlos R. Mafra
7a180b0ef8 WINGs: Add copy_file() to libWUtil
This is essentially the fetchFile() from wcolorpanel.c from the last
commit, but renamed to a better name.

This patch just adds the function to the lib. Nobody uses it yet.
2012-01-15 14:25:07 +00:00
Tamas TEVESZ
14863cd3b1 WINGs: Bounded string ops
Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-07 12:04:31 +02:00
Tamas TEVESZ
d59dacbccd Repair wgethomedir(), broken a little while back
Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-07 12:04:30 +02:00
Tamas TEVESZ
660b61a182 WINGs: Do not look static information up every time
Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-07 12:04:30 +02:00
Tamas TEVESZ
34293e072a Preparing to do exactly as FIXME says
However, knowing about those functions is quite a prerequisite.

Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-07 12:04:30 +02:00
Tamas TEVESZ
1f21919809 Remove wsyserrorwithcode, rename wsyserror to werror
wsyserrorwithcode - Not used, no point either.
wsyserror->werror - qualifying "error" with a "type" hardly makes
sense if there are not at least two "type"s. There are not. Safe trip.

Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
2010-10-07 12:04:30 +02:00
Tamas TEVESZ
9f7aaa8aed Some rework on getstyle
- make it use wings functions, remove duplicated code from getstyle
- de-static necessary functions in wings
- add new wrmdirhier to wings
- rename WMMkDirHier to wmkdirhier (fits better)
- remove calling shell from getstyle (what were they thinking?)

i couldn't quite test getstyle (no idea about themes), but it still
basically works.

do back your ~/G dir up... wrmdirhier might eat it!

definitely needs testing, especially by people who have any idea
how themes work.

Some more getstyle

- missed a shell invocation
- maybe copyFile should be in wutils too...?

[crmafra: Folded second patch into the first]
2010-03-23 21:50:17 +01:00
Tobias Stoeckmann
1db15a3543 Fix multiple errors in findfile.c
Problems:

1.

  During expansion of path, the resulting path can overflow the supplied
  area of PATH_MAX+2 (buffer as well as buffer2). A tampered environment
  variable can be used to modify program flow.

Proof:
      [note: wmaker has been compiled with propolice]
      $ export A="[tested with 4096x A]"
      $ GNUSTEP_USER_ROOT="\$A\$A/\$A/\$A/" wmaker --for-real
      *** stack smashing detected ***: wmaker terminated
      Aborted

2.

  Way too many functions handle a return value of NULL for wexpandpath
  improperly, resulting in segfaults (and maybe other problems). To
  prove the existance of these issues:

Proof:
      $ GNUSTEP_USER_ROOT=~nouser wmaker --for-real
      wmaker error: could not get password entry for user nouser: Success
      Segmentation fault

Solution:

     hard exit with error message about what is going on.

3.

  The improper parsing of environment variables can lead to expansion
  of path names that were not intended to be expanded.

     (a) If a string like "$(var" is found, Window Maker tries to expand "var"
     	 (environment variable) although the syntax is wrong.

Proof:

      $ export PROOF=foo
      $ GNUSTEP_USER_ROOT=/\$\(PROOF wmaker --for-real
      wmaker warning: could not find user GNUstep directory (/foo/Defaults/WindowMaker).

      (b) If the variable out of a) cannot be resolved, a closing bracket will be
      	  added.

Proof:

      $ unset PROOF
      $ GNUSTEP_USER_ROOT=/\$\(PROOF wmaker --for-real
      ./wmaker warning: could not find user GNUstep directory ($(PROOF)/Defaults/WindowMaker).

Author: Tobias Stoeckmann
Retrieved-from: http://paldium.homeunix.org/tobias/wmaker/
Submitted-by: Gilbert Ashley <amigo@ibiblio.org>
2009-08-21 12:13:12 +02:00
Carlos R. Mafra
688a56e8ab Change to the linux kernel coding style
for arq in `git ls-files *.c`; do
    echo $arq;
    indent -linux -l115 $arq;
    done

The different line break at 115 columns is because
I use a widescreen monitor :-)
2009-08-20 00:59:40 +02:00
dan
6830b05716 changed indentation to use spaces only 2004-10-12 21:28:27 +00:00
dan
4153e2fde4 - Fixed crashing bug in menu.c
- Updated year from 2002 to 2003
2003-01-16 23:30:45 +00:00
dan
cab71ba6a1 - Fixed text in info panel for multibyte (Seiichi SATO <ssato@sh.rim.or.jp>)
- Separated the font caches for normal fonts and fontsets in WINGs (they can
  have the same names and collide in the cache giving unwanted results)
- Updated the years in the copyright notices
2002-01-04 07:32:37 +00:00
dan
365556b676 misc selection and textfield fixes 2002-01-02 17:45:40 +00:00
dan
af287fb8eb - added strcasecmp() to WINGs (only on systems that don't have it)
- removed some redundant includes of ../src/config.h where wconfig.h
  is also included
2001-11-17 04:26:08 +00:00
dan
33cc542e85 - Finished moving to the new proplist handling code in WINGs.
- Also tested the backward compatibility ability of the WINGs proplist code
  which seems to work quite well.

Starting with this moment, Window Maker no longer needs libPropList and is
now using the better and much more robust proplist code from WINGs. Also the
WINGs based proplist code is actively maintained while the old libPropList
code is practically dead and flawed by the fact that it borrowed concepts
from the UserDefaults which conflicted with the retain/release mechanism,
making some problems that libPropList had, practically unsolvable without a
complete redesign (which can be found in the more robust WINGs code).
2001-10-04 03:07:34 +00:00
kojima
882b9a8e1c - s/sprintf/snprintf
- updated some po's
- fixed crash bug when removing WINDOWS_MENU or WORKSPACE_MENU from rootmenu
- some other stuff i forgot
2001-07-23 20:31:32 +00:00
kojima
80fb09a74e replaced free() with wfree() everywhere
fixed bug in wlist that caused colorpanel to crash
1999-10-09 20:07:23 +00:00
dan
cd35b67a6b Small fix for an endless loop in findfile.c:wfindfileinarray() 1999-03-17 00:59:36 +00:00
kojima
4eda694989 More WPrefs updates (should I commit changes this often?) 1999-03-16 12:17:14 +00:00
dan
c56756dc73 Update for 0.52.0. This is a test version, which brings the Appearance
section to WPrefs for testing purposes.
1999-03-14 22:35:50 +00:00
dan
0261c32636 Code update for Window Maker version 0.50.0
Read changes in ChangeLog and NEWS
1999-01-06 15:22:33 +00:00
dan
9af1c6c415 Updating to version 0.20.2
Many bug fixes.
1998-10-21 14:43:47 +00:00
scottc
9d2e6ef9f1 Initial revision 1998-09-29 22:36:29 +00:00