This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project wmaker-crm.git.
The branch, next has been updated via 6265af16951565faccb9ee91712d3e10340a045a (commit) via 41f5460e29078a60e38769abaa823b8eebb4b1b0 (commit) via fc229d9bf6aedc6293133de5d1b0731d6949ff2f (commit) via 35d9e113709f53fb881ad66440029fdd13e832e3 (commit) via eef24e8029449ebe6faee98774d2abfd4790833d (commit) via 29d86b1501e1a1e0644487d03baadaaebb5df401 (commit) via ce1763703007d0acf7acfb0cb6fcff34cf3b8cb2 (commit) via b030c840b00ab58279eb3d56ffd306fc0dd0bbab (commit) via 8236505fdfc9495d0b0f226036e7fc484bb717b8 (commit) via 278bd958e5d5db424f7771539a3b4f95a2dd44ea (commit) via 8f1553bced87d835e79e554a53d50aed50b80d92 (commit) via 8704fd36f608caa62fd0bd20a995d7329411e974 (commit) via 5cc3f0d0bffc4db75ae5509aeed6d476cadfc79e (commit) via 2a68274f29f3227705bd23841374d0e3966201b6 (commit) via 73da0c667b1cba5282c1c410734d90bf65e94f5d (commit) via c6b59238fbfa0a7485bef5b3b994c5f11454e791 (commit) via 9860880279eda57fb8fc13148f93b046e02c7a63 (commit) via ca5ec118f0ce84ab8d653953f6fb598858728513 (commit) via 5f5dc351bdecaa2f61a88ae6c376947a95bd6daa (commit) via 179748887ee724ceb24153ba55437217b396a828 (commit) via 34435563e7d7f2c4b6d54a96e5dada635b1aba32 (commit) via 6ee2760673821f1b9b03a4c4224121c15299215e (commit) via 36d95195eb76ab80e7880b8ad4fbea53a5d0bdb8 (commit) via 30d85a007b60d775544d936d7f31b150685f05e3 (commit) via ba06d2683f2b9319c85874f6e8c5e2355088903b (commit) via e602ac87680e7ec6940ab82d9b805d828367a14a (commit) via 8dcfd3568a4e6d207a400d7d0860cebd1d9586b4 (commit) via 4a857f18d0cb74cdb183e821c1246ae9fd21da16 (commit) via ec1660dc499b33a2311888ccee6aa73c95de78ca (commit) via 1f2dd583bee10399a86dc636286e4dd7e6ad376b (commit) via 3e1ef70248298e14efb9458843ade4355f103e67 (commit) via 0e5e36eb663fada470e1dfc9aadf62fa8669de06 (commit) from 0c294040a18ff7ec331818ea00f0ffb451234767 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://repo.or.cz/w/wmaker-crm.git/commit/6265af16951565faccb9ee91712d3e10340a045a commit 6265af16951565faccb9ee91712d3e10340a045a Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:41:00 2014 +0100 WPrefs: add check for image validity in 'loadRImage' (Coverity #50221, #50081) As pointed by Coverity, the function blindly trust the data read from the file, but in case of problem (corrupted file, not enough memory) it could behave badly. This patch adds a check for the depth, counts on RCreateImage to check the width and height, and in any case it now includes a message for the user in case he would like to understand what's wrong. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WPrefs.app/Appearance.c b/WPrefs.app/Appearance.c index 53ee1daa..7e22dec9 100644 --- a/WPrefs.app/Appearance.c +++ b/WPrefs.app/Appearance.c @@ -1310,10 +1310,22 @@ static Pixmap loadRImage(WMScreen * scr, const char *path) cnt = fscanf(f, "%02x%02x%1x", &w, &h, &d); if (cnt != 3) { + wwarning(_("could not read size of image from '%s', ignoring"), path); + fclose(f); + return None; + } + if (d < 3 || d > 4) { + wwarning(_("image "%s" has an invalid depth of %d, ignoring"), path, d); fclose(f); return None; } image = RCreateImage(w, h, d == 4); + if (image == NULL) { + wwarning(_("could not create RImage for "%s": %s"), + path, RMessageForError(RErrorCode)); + fclose(f); + return None; + } read_size = w * h * d; if (fread(image->data, 1, read_size, f) == read_size) RConvertImage(WMScreenRContext(scr), image, &pixmap); http://repo.or.cz/w/wmaker-crm.git/commit/41f5460e29078a60e38769abaa823b8eebb4b1b0 commit 41f5460e29078a60e38769abaa823b8eebb4b1b0 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:59 2014 +0100 WPrefs: fix possible buffer overrun (Coverity #50216) As pointed by Coverity, if the Keysym name is very long and many modifiers are used, the function 'capture_shortcut' could overflow its internal buffer. As the case is very unlikely to appear, do not increase the size of the internal buffer (it seems to be already well sized, and we have no know maximum size for a Keysym name), just use the appropriate function to append the name at the end. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c index 418b2397..414d479f 100644 --- a/WPrefs.app/KeyboardShortcuts.c +++ b/WPrefs.app/KeyboardShortcuts.c @@ -356,7 +356,7 @@ char *capture_shortcut(Display *dpy, Bool *capturing, Bool convert_case) if ((numlock_mask != Mod5Mask) && (ev.xkey.state & Mod5Mask)) strcat(buffer, "Mod5+"); - strcat(buffer, key); + wstrlcat(buffer, key, sizeof(buffer)); return wstrdup(buffer); } http://repo.or.cz/w/wmaker-crm.git/commit/fc229d9bf6aedc6293133de5d1b0731d6949ff2f commit fc229d9bf6aedc6293133de5d1b0731d6949ff2f Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:58 2014 +0100 WPrefs: remove fuzzy translation that are likely to puzzle user Unfortunately this will lower the translation score for German, but the translation guessed by fuzzy matching in gettext is not acceptable in the current case: the translated string is already used for another entry in the list, meaning that user would not see the difference between the two and would probably then not understand why things do not behave the way he expects. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WPrefs.app/po/de.po b/WPrefs.app/po/de.po index 99dcedb1..fe60b4d4 100644 --- a/WPrefs.app/po/de.po +++ b/WPrefs.app/po/de.po @@ -702,14 +702,12 @@ msgid "Focus previous window" msgstr "Vorheriges Fenster" #: ../../WPrefs.app/KeyboardShortcuts.c:488 -#, fuzzy msgid "Focus next group window" -msgstr "Nächstes Fenster" +msgstr "" #: ../../WPrefs.app/KeyboardShortcuts.c:489 -#, fuzzy msgid "Focus previous group window" -msgstr "Vorheriges Fenster" +msgstr "" #: ../../WPrefs.app/KeyboardShortcuts.c:490 msgid "Switch to next workspace" http://repo.or.cz/w/wmaker-crm.git/commit/35d9e113709f53fb881ad66440029fdd13e832e3 commit 35d9e113709f53fb881ad66440029fdd13e832e3 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:57 2014 +0100 wmaker: fix size of element given to the 'qsort' function (Coverity #50210) As pointed by Coverity, the sizeof used was not done on the right type. This worked because the element was a pointer all pointers types have the same size in most platforms. For code maintainability, the code will now take the size from the first element of the array to be sorted, so that if the structure gets changed someday the expression will stay valid. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/moveres.c b/src/moveres.c index e00b3ed8..8640511c 100644 --- a/src/moveres.c +++ b/src/moveres.c @@ -776,10 +776,10 @@ static void updateMoveData(WWindow * wwin, MoveData * data) /* order from closest to the border of the screen to farthest */ - qsort(data->topList, data->count, sizeof(WWindow **), compareWTop); - qsort(data->leftList, data->count, sizeof(WWindow **), compareWLeft); - qsort(data->rightList, data->count, sizeof(WWindow **), compareWRight); - qsort(data->bottomList, data->count, sizeof(WWindow **), compareWBottom); + qsort(data->topList, data->count, sizeof(data->topList[0]), compareWTop); + qsort(data->leftList, data->count, sizeof(data->leftList[0]), compareWLeft); + qsort(data->rightList, data->count, sizeof(data->rightList[0]), compareWRight); + qsort(data->bottomList, data->count, sizeof(data->bottomList[0]), compareWBottom); /* figure the position of the window relative to the others */ http://repo.or.cz/w/wmaker-crm.git/commit/eef24e8029449ebe6faee98774d2abfd4790833d commit eef24e8029449ebe6faee98774d2abfd4790833d Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:56 2014 +0100 wmaker: removed case from switch that is unreachable (Coverity #50043) There is a check a few line above that already return from the function because there is nothing to do for that case, so the case statement cannot be reached. As not all case are covered in that switch anyway that won't make a difference, and because an 'int' is used instead of an 'enum' the compiler will not be able complain anyway. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/texture.c b/src/texture.c index c73c85a0..e69fe485 100644 --- a/src/texture.c +++ b/src/texture.c @@ -541,8 +541,6 @@ void wDrawBevel(Drawable d, unsigned width, unsigned height, WTexSolid * texture dim = texture->dim_gc; dark = texture->dark_gc; switch (relief) { - case WREL_FLAT: - return; case WREL_MENUENTRY: case WREL_RAISED: case WREL_ICON: http://repo.or.cz/w/wmaker-crm.git/commit/29d86b1501e1a1e0644487d03baadaaebb5df401 commit 29d86b1501e1a1e0644487d03baadaaebb5df401 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:55 2014 +0100 wmaker: change message to have only one string to translate and to have more information The warning message was duplicated many times for each possible case, but it could have used the same message everywhere, which ease the work of translators. Took opportunity to include the complete command being processed so that the user will know more about the problem and may be able to fix it. Updated the French translation to show the gain, but not the other languages because it require more knowledge than what Google Translate can provide me. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/po/fr.po b/po/fr.po index 0bc34393..d163709f 100644 --- a/po/fr.po +++ b/po/fr.po @@ -1108,21 +1108,9 @@ msgid "out of memory during expansion of "%s"" msgstr "Plus assez de mémoire pendant l'interprétation de « %s »." #: ../src/misc.c:863 -msgid "out of memory during expansion of "%w"" -msgstr "Plus assez de mémoire pendant l'interprétation de « %w »." - -#: ../src/misc.c:881 -msgid "out of memory during expansion of "%W"" -msgstr "Plus assez de mémoire pendant l'interprétation de « %W »." - -#: ../src/misc.c:897 -msgid "out of memory during expansion of "%a"" -msgstr "Plus assez de mémoire pendant l'interprétation de « %a »." - -#: ../src/misc.c:928 #, c-format -msgid "out of memory during expansion of "%d"" -msgstr "Plus assez de mémoire pendant l'interprétation de « %d »." +msgid "out of memory during expansion of '%s' for command "%s"" +msgstr "Plus assez de mémoire pour l'interprétation du « %s » dans la commande « %s »" #: ../src/misc.c:942 msgid "selection not available" diff --git a/src/misc.c b/src/misc.c index fdaae743..51eb1ee6 100644 --- a/src/misc.c +++ b/src/misc.c @@ -575,7 +575,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline) olen += slen; nout = realloc(out, olen); if (!nout) { - wwarning(_("out of memory during expansion of "%%w"")); + wwarning(_("out of memory during expansion of '%s' for command "%s""), "%w", cmdline); goto error; } out = nout; @@ -592,7 +592,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline) olen += slen; nout = realloc(out, olen); if (!nout) { - wwarning(_("out of memory during expansion of "%%W"")); + wwarning(_("out of memory during expansion of '%s' for command "%s""), "%W", cmdline); goto error; } out = nout; @@ -609,7 +609,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline) olen += slen; nout = realloc(out, olen); if (!nout) { - wwarning(_("out of memory during expansion of "%%a"")); + wwarning(_("out of memory during expansion of '%s' for command "%s""), "%a", cmdline); goto error; } out = nout; @@ -632,7 +632,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline) olen += slen; nout = realloc(out, olen); if (!nout) { - wwarning(_("out of memory during expansion of "%%d"")); + wwarning(_("out of memory during expansion of '%s' for command "%s""), "%d", cmdline); goto error; } out = nout; @@ -653,7 +653,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline) olen += slen; nout = realloc(out, olen); if (!nout) { - wwarning(_("out of memory during expansion of "%%s"")); + wwarning(_("out of memory during expansion of '%s' for command "%s""), "%s", cmdline); goto error; } out = nout; http://repo.or.cz/w/wmaker-crm.git/commit/ce1763703007d0acf7acfb0cb6fcff34cf3b8cb2 commit ce1763703007d0acf7acfb0cb6fcff34cf3b8cb2 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:54 2014 +0100 wmaker: do not duplicate a string that does not need to be (Coverity #72814) As coverity pointed, the duplicated string was never freed. Considering what is done with it, is not necessary to allocate a duplicate for it, it is a waste of time and participates in memory fragmentation. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/misc.c b/src/misc.c index 3e73ff8f..fdaae743 100644 --- a/src/misc.c +++ b/src/misc.c @@ -515,9 +515,6 @@ char *ExpandOptions(WScreen *scr, const char *cmdline) char *out, *nout; char *selection = NULL; char *user_input = NULL; -#ifdef XDND - char *dropped_thing = NULL; -#endif char tmpbuf[TMPBUFSIZE]; int slen; @@ -627,14 +624,11 @@ char *ExpandOptions(WScreen *scr, const char *cmdline) #ifdef XDND case 'd': - if (scr->xdestring) { - dropped_thing = wstrdup(scr->xdestring); - } - if (!dropped_thing) { + if (!scr->xdestring) { scr->flags.dnd_data_convertion_status = 1; goto error; } - slen = strlen(dropped_thing); + slen = strlen(scr->xdestring); olen += slen; nout = realloc(out, olen); if (!nout) { @@ -642,7 +636,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline) goto error; } out = nout; - strcat(out, dropped_thing); + strcat(out, scr->xdestring); optr += slen; break; #endif /* XDND */ http://repo.or.cz/w/wmaker-crm.git/commit/b030c840b00ab58279eb3d56ffd306fc0dd0bbab commit b030c840b00ab58279eb3d56ffd306fc0dd0bbab Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:53 2014 +0100 wmaker: update error message to have only one string to be translated As a previous patch modified some instances of the error message to include more information to the user, it is a good idea to update also the other uses of the message, so that: - people helping on translation will have less messages to translate - this mean we provide more information to the user in these places too, which can help him solve the problem Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/po/be.po b/po/be.po index ea74e56c..846452a1 100644 --- a/po/be.po +++ b/po/be.po @@ -1263,8 +1263,8 @@ msgstr "%s: немагчыма адкрыць ці апрацаваць файл #: ../src/rootmenu.c:1212 ../src/rootmenu.c:1315 #, c-format -msgid "%s:could not open menu file" -msgstr "%s: немагчыма адкрыць файл меню" +msgid "could not open menu file "%s": %s" +msgstr "немагчыма адкрыць файл меню "%s": %s" #: ../src/rootmenu.c:1239 #, c-format diff --git a/po/bg.po b/po/bg.po index dd01bc3e..5a8d396c 100644 --- a/po/bg.po +++ b/po/bg.po @@ -1557,8 +1557,8 @@ msgstr "%s: не може да се отвори/обработи от пред # ../src/rootmenu.c:1123 ../src/rootmenu.c:1224 #: ../src/rootmenu.c:1212 ../src/rootmenu.c:1315 #, c-format -msgid "%s:could not open menu file" -msgstr "%s: не може да се отвори файлът меню" +msgid "could not open menu file "%s": %s" +msgstr "не може да се отвори файлът меню "%s": %s" # ../src/rootmenu.c:1150 #: ../src/rootmenu.c:1239 diff --git a/po/bs.po b/po/bs.po index d8a386cb..76b99a31 100644 --- a/po/bs.po +++ b/po/bs.po @@ -745,8 +745,8 @@ msgid "%s:could not open/preprocess menu file" msgstr "%s:ne mogu otvoriti/preprocesirati datoteku izbornika" #: ../src/rootmenu.c:1079 ../src/rootmenu.c:1180 -msgid "%s:could not open menu file" -msgstr "%s: ne mogu otvoriti datoteku izbornika" +msgid "could not open menu file "%s": %s" +msgstr "ne mogu otvoriti datoteku izbornika "%s": %s" #: ../src/rootmenu.c:1106 msgid "%s:invalid menu file. MENU command is missing" diff --git a/po/ca.po b/po/ca.po index 71e0cfdb..96eec2b4 100644 --- a/po/ca.po +++ b/po/ca.po @@ -1299,8 +1299,8 @@ msgstr "%s: no s'ha pogut obrir/preprocessar el fitxer de menú" #: ../src/rootmenu.c:1217 ../src/rootmenu.c:1321 #, c-format -msgid "%s:could not open menu file" -msgstr "%s: no s'ha pogut obrir el fitxer de menú" +msgid "could not open menu file "%s": %s" +msgstr "no s'ha pogut obrir el fitxer de menú "%s": %s" #: ../src/rootmenu.c:1244 #, c-format diff --git a/po/cs.po b/po/cs.po index 0e41b97c..8a7d0e8e 100644 --- a/po/cs.po +++ b/po/cs.po @@ -1221,8 +1221,8 @@ msgstr "%s: nelze otevřít nebo předzpracovat soubor s menu" #: ../src/rootmenu.c:1175 ../src/rootmenu.c:1277 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:nelze otevřít soubor s menu" +msgid "could not open menu file "%s": %s" +msgstr "nelze otevřít soubor s menu "%s": %s" #: ../src/rootmenu.c:1202 #, c-format diff --git a/po/da.po b/po/da.po index 154d674a..6d6242e7 100644 --- a/po/da.po +++ b/po/da.po @@ -1483,8 +1483,8 @@ msgstr "%s:kunne ikke åbne/forbehandle menufil" # ../src/rootmenu.c:1126 ../src/rootmenu.c:1227 #: ../src/rootmenu.c:1212 ../src/rootmenu.c:1314 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:kunne ikke åbne menufil" +msgid "could not open menu file "%s": %s" +msgstr "kunne ikke åbne menufil "%s": %s" # ../src/rootmenu.c:1153 #: ../src/rootmenu.c:1239 diff --git a/po/de.po b/po/de.po index 669f661e..5273b273 100644 --- a/po/de.po +++ b/po/de.po @@ -1164,8 +1164,8 @@ msgstr "%s: Menüdatei konnte nicht geöffnet/bearbeitet werden" #: ../src/rootmenu.c:1106 ../src/rootmenu.c:1203 #, c-format -msgid "%s:could not open menu file" -msgstr "%s: Menüdatei konnte nicht geöffnet werden" +msgid "could not open menu file "%s": %s" +msgstr "Menüdatei "%s" konnte nicht geöffnet werden: %s" #: ../src/rootmenu.c:1132 #, c-format diff --git a/po/es.po b/po/es.po index 7e087e26..066f5446 100644 --- a/po/es.po +++ b/po/es.po @@ -1161,8 +1161,8 @@ msgstr "%s:no se pudo abrir/preprocesar el fichero de menú" #: ../src/rootmenu.c:1105 ../src/rootmenu.c:1199 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:no se pudo abrir el fichero del menú" +msgid "could not open menu file "%s": %s" +msgstr "no se pudo abrir el fichero del menú "%s": %s" #: ../src/rootmenu.c:1131 #, c-format diff --git a/po/et.po b/po/et.po index 0208f0eb..dc7f4eec 100644 --- a/po/et.po +++ b/po/et.po @@ -1147,8 +1147,8 @@ msgstr "%s:menüüfaili pole võimalik avada või eeltöödelda" #: ../src/rootmenu.c:1064 ../src/rootmenu.c:1149 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:menüüfaili pole võimalik avada" +msgid "could not open menu file "%s": %s" +msgstr "menüüfaili "%s" pole võimalik avada: %s" #: ../src/rootmenu.c:1084 #, c-format diff --git a/po/fi.po b/po/fi.po index 88e2f808..8f599ede 100644 --- a/po/fi.po +++ b/po/fi.po @@ -1210,8 +1210,8 @@ msgstr "%s: valikkotiedostoa ei voitu avata/esikäsitellä" #: ../src/rootmenu.c:1174 ../src/rootmenu.c:1276 #, c-format -msgid "%s:could not open menu file" -msgstr "%s: valikkotiedoston avaus ei onnistunut" +msgid "could not open menu file "%s": %s" +msgstr "valikkotiedoston "%s" avaus ei onnistunut: %s" #: ../src/rootmenu.c:1201 #, c-format diff --git a/po/fr.po b/po/fr.po index 8e4cd84e..0bc34393 100644 --- a/po/fr.po +++ b/po/fr.po @@ -1283,8 +1283,8 @@ msgstr "%s : échec à l'ouverture ou au traitement du fichier de menu." #: ../src/rootmenu.c:1217 ../src/rootmenu.c:1320 #, c-format -msgid "%s:could not open menu file" -msgstr "%s : l'ouverture du fichier de menu a échoué." +msgid "could not open menu file "%s": %s" +msgstr "l'ouverture du fichier de menu "%s" a échoué: %s" #: ../src/rootmenu.c:1244 #, c-format diff --git a/po/gl.po b/po/gl.po index 575fb665..79157ed7 100644 --- a/po/gl.po +++ b/po/gl.po @@ -1061,8 +1061,8 @@ msgstr "%s:non foi posible abrir/preprocesar ficheiro de menú" #: ../src/rootmenu.c:1123 ../src/rootmenu.c:1224 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:non foi posible abri-lo ficheiro de menú" +msgid "could not open menu file "%s": %s" +msgstr "non foi posible abri-lo ficheiro de menú "%s": %s" #: ../src/rootmenu.c:1150 #, c-format diff --git a/po/hr.po b/po/hr.po index 2372acfc..6c992464 100644 --- a/po/hr.po +++ b/po/hr.po @@ -744,8 +744,8 @@ msgid "%s:could not open/preprocess menu file" msgstr "%s:ne mogu otvoriti/preprocesirati datoteku izbornika" #: ../src/rootmenu.c:1079 ../src/rootmenu.c:1180 -msgid "%s:could not open menu file" -msgstr "%s: ne mogu otvoriti datoteku izbornika" +msgid "could not open menu file "%s": %s" +msgstr "ne mogu otvoriti datoteku izbornika "%s": %s" #: ../src/rootmenu.c:1106 msgid "%s:invalid menu file. MENU command is missing" diff --git a/po/hu.po b/po/hu.po index 43418fea..10d14289 100644 --- a/po/hu.po +++ b/po/hu.po @@ -1179,8 +1179,8 @@ msgstr "szintaktikai hiba a menü fájlban: hiányzó END kulcsszó" #: ../../wmaker-crm/src/rootmenu.c:1049 ../../wmaker-crm/src/rootmenu.c:1138 #, c-format -msgid "%s:could not open menu file" -msgstr "%s: nem tudom megnyitni a menü fájlt" +msgid "could not open menu file "%s": %s" +msgstr "nem tudom megnyitni a menü fájlt "%s": %s" #: ../../wmaker-crm/src/rootmenu.c:1072 msgid "invalid menu file, MENU command is missing" diff --git a/po/it.po b/po/it.po index 6f015936..53bbc8a8 100644 --- a/po/it.po +++ b/po/it.po @@ -1234,11 +1234,10 @@ msgstr "impossibile generare gli argomenti per il preprocessore del file di men msgid "%s:could not open/preprocess menu file" msgstr "%s: impossibile aprire/preelaborare il file di menù" -# FIXME UPSTREAM< #: ../src/rootmenu.c:1217 ../src/rootmenu.c:1321 #, c-format -msgid "%s:could not open menu file" -msgstr "%s: impossibile aprire il file di menù" +msgid "could not open menu file "%s": %s" +msgstr "impossibile aprire il file di menù "%s": %s" # FIXME UPSTREAM< #: ../src/rootmenu.c:1244 diff --git a/po/ja.po b/po/ja.po index f0db60ab..93b51898 100644 --- a/po/ja.po +++ b/po/ja.po @@ -1137,8 +1137,8 @@ msgstr "%s:メニューファイルのオープン/プリプロセスができ #: ../src/rootmenu.c:1105 ../src/rootmenu.c:1199 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:メニューファイルを開けません" +msgid "could not open menu file "%s": %s" +msgstr "メニューファイルを開けません "%s": %s" #: ../src/rootmenu.c:1131 #, c-format diff --git a/po/ko.po b/po/ko.po index d2455f79..831b0182 100644 --- a/po/ko.po +++ b/po/ko.po @@ -1121,8 +1121,8 @@ msgstr "메뉴 파일에서 문법 오류: END 선언 없음" #: ../src/rootmenu.c:1025 ../src/rootmenu.c:1114 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:메뉴 파일을 열 수 없음" +msgid "could not open menu file "%s": %s" +msgstr "메뉴 파일을 열 수 없음 "%s": %s" #: ../src/rootmenu.c:1048 msgid "invalid menu file, MENU command is missing" diff --git a/po/ms.po b/po/ms.po index 8a465be6..04ddec69 100644 --- a/po/ms.po +++ b/po/ms.po @@ -1244,8 +1244,8 @@ msgstr "%s:tak dapat membuka/mempraproses fail menu)" #: ../src/rootmenu.c:1209 ../src/rootmenu.c:1311 #, c-format -msgid "%s:could not open menu file" -msgstr "%s: tak dapat membuka fail menu" +msgid "could not open menu file "%s": %s" +msgstr "tak dapat membuka fail menu "%s": %s" #: ../src/rootmenu.c:1236 #, c-format diff --git a/po/nl.po b/po/nl.po index a54c5557..88c72327 100644 --- a/po/nl.po +++ b/po/nl.po @@ -1204,8 +1204,8 @@ msgstr "ongeldig menu, geen menutitel opgegeven" #: ../src/rootmenu.c:1096 ../src/rootmenu.c:1156 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:kon menubestand niet openen" +msgid "could not open menu file "%s": %s" +msgstr "kon menubestand "%s" niet openen: %s" #: ../src/rootmenu.c:1264 ../src/rootmenu.c:1336 ../src/rootmenu.c:1375 #, c-format diff --git a/po/no.po b/po/no.po index eb58dd16..0a908b2d 100644 --- a/po/no.po +++ b/po/no.po @@ -484,8 +484,8 @@ msgstr "%s:kunne ikke åpne/behandle meny filen" #: ../src/rootmenu.c:685 ../src/rootmenu.c:767 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:kunne ikke åpne meny filen" +msgid "could not open menu file "%s": %s" +msgstr "kunne ikke åpne meny filen "%s": %s" #: ../src/rootmenu.c:698 #, c-format diff --git a/po/pl.po b/po/pl.po index adfd1cb3..af594321 100644 --- a/po/pl.po +++ b/po/pl.po @@ -842,8 +842,8 @@ msgstr "%s:nie można otworzyć/przetworzyć pliku menu" #: ../src/rootmenu.c:1096 ../src/rootmenu.c:1197 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:nie można otworzyć pliku menu" +msgid "could not open menu file "%s": %s" +msgstr "nie można otworzyć pliku menu "%s": %s" #: ../src/rootmenu.c:1123 #, c-format diff --git a/po/pt.po b/po/pt.po index 7be44584..0f1fc39a 100644 --- a/po/pt.po +++ b/po/pt.po @@ -1050,8 +1050,8 @@ msgstr "%s:não foi possível abrir/preprocessar arquivo de menu" #: ../src/rootmenu.c:1123 ../src/rootmenu.c:1224 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:não foi possível abrir arquivo de menu" +msgid "could not open menu file "%s": %s" +msgstr "não foi possível abrir arquivo de menu "%s": %s" #: ../src/rootmenu.c:1150 #, c-format diff --git a/po/ru.po b/po/ru.po index cd88c86c..cbcc1c9a 100644 --- a/po/ru.po +++ b/po/ru.po @@ -1260,8 +1260,8 @@ msgstr "%s:не удалось открыть/предобработать фа #: ../src/rootmenu.c:1212 ../src/rootmenu.c:1315 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:не удалось открыть файл меню" +msgid "could not open menu file "%s": %s" +msgstr "не удалось открыть файл меню "%s": %s" #: ../src/rootmenu.c:1239 #, c-format diff --git a/po/sk.po b/po/sk.po index 53d25d48..ca9db10c 100644 --- a/po/sk.po +++ b/po/sk.po @@ -1308,8 +1308,8 @@ msgstr "%s:nemožno otvoriť alebo predspracovať súbor s menu" #: ../src/rootmenu.c:1217 ../src/rootmenu.c:1321 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:nemožno otvoriť súbor s menu" +msgid "could not open menu file "%s": %s" +msgstr "nemožno otvoriť súbor s menu "%s": %s" #: ../src/rootmenu.c:1244 #, c-format diff --git a/po/tr.po b/po/tr.po index 2adb9235..57bbc61f 100644 --- a/po/tr.po +++ b/po/tr.po @@ -650,8 +650,8 @@ msgid "%s:could not open/preprocess menu file" msgstr "%s:menü dosyası açılamadı/işlenemedi" #: ../src/rootmenu.c:1033 ../src/rootmenu.c:1131 -msgid "%s:could not open menu file" -msgstr "%s: menü dosyası açılamadı" +msgid "could not open menu file "%s": %s" +msgstr "menü dosyası "%s" açılamadı: %s" #: ../src/rootmenu.c:1060 msgid "%s:invalid menu file" diff --git a/po/zh_CN.po b/po/zh_CN.po index 9743664f..5af76c33 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -990,8 +990,8 @@ msgstr "%s:不能打开或预处理菜单文件" #: ../src/rootmenu.c:1126 ../src/rootmenu.c:1227 #, c-format -msgid "%s:could not open menu file" -msgstr "%s:不能打开菜单文件" +msgid "could not open menu file "%s": %s" +msgstr "不能打开菜单文件 "%s": %s" #: ../src/rootmenu.c:1153 #, c-format diff --git a/po/zh_TW.po b/po/zh_TW.po index e2ad8dba..6bac9ac3 100644 --- a/po/zh_TW.po +++ b/po/zh_TW.po @@ -1205,8 +1205,8 @@ msgstr "%s: 無法開啟/預先處理選單檔" #: ../src/rootmenu.c:1217 ../src/rootmenu.c:1321 #, c-format -msgid "%s:could not open menu file" -msgstr "%s: 無法開啟選單檔" +msgid "could not open menu file "%s": %s" +msgstr "無法開啟選單檔 "%s": %s" #: ../src/rootmenu.c:1244 #, c-format diff --git a/src/rootmenu.c b/src/rootmenu.c index aff00c19..8c0f0c68 100644 --- a/src/rootmenu.c +++ b/src/rootmenu.c @@ -1094,7 +1094,7 @@ static WMenu *readMenuFile(WScreen *scr, const char *file_name) file = fopen(file_name, "rb"); if (!file) { - werror(_("%s:could not open menu file"), file_name); + werror(_("could not open menu file "%s": %s"), file_name, strerror(errno)); return NULL; } menu = readMenu(scr, file_name, file); @@ -1172,9 +1172,15 @@ static WMenu *readMenuPipe(WScreen * scr, char **file_name) } filename = flat_file + (flat_file[1] == '|' ? 2 : 1); + /* + * In case of memory problem, 'popen' will not set the errno, so we initialise it + * to be able to display a meaningful message. For other problems, 'popen' will + * properly set errno, so we'll still get a good message + */ + errno = ENOMEM; file = popen(filename, "r"); if (!file) { - werror(_("%s:could not open menu file"), filename); + werror(_("could not open menu file "%s": %s"), filename, strerror(errno)); return NULL; } menu = readMenu(scr, flat_file, file); http://repo.or.cz/w/wmaker-crm.git/commit/8236505fdfc9495d0b0f226036e7fc484bb717b8 commit 8236505fdfc9495d0b0f226036e7fc484bb717b8 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:52 2014 +0100 wmaker: fix possible buffer overrun in readMenuPipe (Coverity #50211, #50212) As Coverity pointed, when building the command line to execute the current code just assumed that it would fit in the large buffer. If user were to provide a line too long, this would crash. Factually this is probably not possible at current time because the command given to the function was actually already limited to the MAXLINE size when it was read, but this may not be guaranteed in future evolution. Better safe than sorry, so the patch implement a size check when appending strings, using a more efficient method (strcat re-parse the destination string from the beginning to find its end every time). Took the opportunity to: - not include a trailing space at the end of the command - do not run command if it was truncated (it could be a problem) but provide a message to the user about it, so he may fix the problem Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/rootmenu.c b/src/rootmenu.c index fca0cb72..aff00c19 100644 --- a/src/rootmenu.c +++ b/src/rootmenu.c @@ -34,6 +34,7 @@ #include <ctype.h> #include <time.h> #include <dirent.h> +#include <errno.h> #include <X11/Xlib.h> #include <X11/Xutil.h> @@ -1102,6 +1103,30 @@ static WMenu *readMenuFile(WScreen *scr, const char *file_name) return menu; } +static inline int generate_command_from_list(char *buffer, size_t buffer_size, char **command_elements) +{ + char *rd; + int wr_idx; + int i; + + wr_idx = 0; + for (i = 0; command_elements[i] != NULL; i++) { + + if (i > 0) + if (wr_idx < buffer_size - 1) + buffer[wr_idx++] = ' '; + + for (rd = command_elements[i]; *rd != '0'; rd++) { + if (wr_idx < buffer_size - 1) + buffer[wr_idx++] = *rd; + else + return 1; + } + } + buffer[wr_idx] = '0'; + return 0; +} + /************ Menu Configuration From Pipe *************/ static WMenu *readPLMenuPipe(WScreen * scr, char **file_name) { @@ -1109,13 +1134,11 @@ static WMenu *readPLMenuPipe(WScreen * scr, char **file_name) WMenu *menu = NULL; char *filename; char flat_file[MAXLINE]; - int i; - - flat_file[0] = '0'; - for (i = 0; file_name[i] != NULL; i++) { - strcat(flat_file, file_name[i]); - strcat(flat_file, " "); + if (generate_command_from_list(flat_file, sizeof(flat_file), file_name)) { + werror(_("could not open menu file "%s": %s"), + file_name[0], _("pipe command for PropertyList is too long")); + return NULL; } filename = flat_file + (flat_file[1] == '|' ? 2 : 1); @@ -1141,13 +1164,11 @@ static WMenu *readMenuPipe(WScreen * scr, char **file_name) FILE *file = NULL; char *filename; char flat_file[MAXLINE]; - int i; - flat_file[0] = '0'; - - for (i = 0; file_name[i] != NULL; i++) { - strcat(flat_file, file_name[i]); - strcat(flat_file, " "); + if (generate_command_from_list(flat_file, sizeof(flat_file), file_name)) { + werror(_("could not open menu file "%s": %s"), + file_name[0], _("pipe command is too long")); + return NULL; } filename = flat_file + (flat_file[1] == '|' ? 2 : 1); http://repo.or.cz/w/wmaker-crm.git/commit/278bd958e5d5db424f7771539a3b4f95a2dd44ea commit 278bd958e5d5db424f7771539a3b4f95a2dd44ea Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:51 2014 +0100 wmaker: fixes in function 'UnescapeWM_CLASS' (Coverity #50101, #50186, #50187) As coverity found a number of problem in the code, a few changes are made to the function: - allocate better sizes for the strings (the original code allocated too much room in many cases and missed the room for the final '0' in a case) - do not free strings if empty anymore (the actual check was not correct anyway), but avoid allocating in first place if it is not necessary. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/misc.c b/src/misc.c index b4c71023..3e73ff8f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -862,16 +862,14 @@ char *EscapeWM_CLASS(const char *name, const char *class) static void UnescapeWM_CLASS(const char *str, char **name, char **class) { int i, j, k, dot; + int length_of_name; j = strlen(str); - *name = wmalloc(j); - **name = 0; - *class = wmalloc(j); - **class = 0; /* separate string in 2 parts */ + length_of_name = 0; dot = -1; - for (i = 0; i < j; i++) { + for (i = 0; i < j; i++, length_of_name++) { if (str[i] == '\') { i++; continue; @@ -881,31 +879,27 @@ static void UnescapeWM_CLASS(const char *str, char **name, char **class) } } - /* unescape strings */ - for (i = 0, k = 0; i < dot; i++) { - if (str[i] == '\') { - continue; - } else { - (*name)[k++] = str[i]; + /* unescape the name */ + if (length_of_name > 0) { + *name = wmalloc(length_of_name + 1); + for (i = 0, k = 0; i < dot; i++) { + if (str[i] != '\') + (*name)[k++] = str[i]; } + (*name)[k] = '0'; + } else { + *name = NULL; } - (*name)[k] = 0; - for (i = dot + 1, k = 0; i < j; i++) { - if (str[i] == '\') { - continue; - } else { - (*class)[k++] = str[i]; + /* unescape the class */ + if (dot < j-1) { + *class = wmalloc(j - (dot + 1) + 1); + for (i = dot + 1, k = 0; i < j; i++) { + if (str[i] != '\') + (*class)[k++] = str[i]; } - } - (*class)[k] = 0; - - if (!*name) { - wfree(*name); - *name = NULL; - } - if (!*class) { - wfree(*class); + (*class)[k] = 0; + } else { *class = NULL; } } http://repo.or.cz/w/wmaker-crm.git/commit/8f1553bced87d835e79e554a53d50aed50b80d92 commit 8f1553bced87d835e79e554a53d50aed50b80d92 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:50 2014 +0100 wmaker: fix memory leak in get_icon_filename (Coverity #50132) Coverity pointed that in the typical code path the function FindImage would be called twice, leading in leakage of the allocated result from the first call. This patch updates the condition so that the case won't arise. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/wdefaults.c b/src/wdefaults.c index 3371e710..c2d9eb80 100644 --- a/src/wdefaults.c +++ b/src/wdefaults.c @@ -375,8 +375,8 @@ static WMPropList *get_generic_value(const char *instance, const char *class, char *get_icon_filename(const char *winstance, const char *wclass, const char *command, Bool default_icon) { - char *file_name = NULL; - char *file_path = NULL; + char *file_name; + char *file_path; /* Get the file name of the image, using instance and class */ file_name = wDefaultGetIconFile(winstance, wclass, default_icon); @@ -384,30 +384,33 @@ char *get_icon_filename(const char *winstance, const char *wclass, const char *c /* Check if the file really exists in the disk */ if (file_name) file_path = FindImage(wPreferences.icon_path, file_name); + else + file_path = NULL; /* If the specific icon filename is not found, and command is specified, * then include the .app icons and re-do the search. */ - if ((!file_name || !file_path ) && command) { + if (!file_path && command) { wApplicationExtractDirPackIcon(command, winstance, wclass); file_name = wDefaultGetIconFile(winstance, wclass, False); - } - - /* Get the full path for the image file */ - if (file_name) { - file_path = FindImage(wPreferences.icon_path, file_name); - if (!file_path) - wwarning(_("icon "%s" doesn't exist, check your config files"), file_name); + if (file_name) { + file_path = FindImage(wPreferences.icon_path, file_name); + if (!file_path) + wwarning(_("icon "%s" doesn't exist, check your config files"), file_name); - /* FIXME: Here, if file_path don't exists, then the icon is in the - * "icon database" (w_global.domain.window_attr->dictionary), but the icon - * is not en disk. Therefore, we should remove it from the icon - * database. Is possible to do that using wDefaultChangeIcon() */ - - /* Don't wfree(file_name) here, because is a pointer to the icon - * dictionary (w_global.domain.window_attr->dictionary) value. */ + /* FIXME: Here, if file_path does not exist then the icon is still in the + * "icon database" (w_global.domain.window_attr->dictionary), but the file + * for the icon is no more on disk. Therefore, we should remove it from the + * database. Is possible to do that using wDefaultChangeIcon() */ + } } + /* + * Don't wfree(file_name) because it is a direct pointer inside the icon + * dictionary (w_global.domain.window_attr->dictionary) and not a result + * allocated with wstrdup() + */ + if (!file_path && default_icon) file_path = get_default_image_path(); http://repo.or.cz/w/wmaker-crm.git/commit/8704fd36f608caa62fd0bd20a995d7329411e974 commit 8704fd36f608caa62fd0bd20a995d7329411e974 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:49 2014 +0100 wmaker: remove unnecessary null check in readMenuDirectory (Coverity #50190) As pointed by Coverity, the pointer cannot be null, otherwise the code would have crashed earlier. As the code seems to always set a valid pointer, there's no need to make a check there. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/rootmenu.c b/src/rootmenu.c index 13032044..fca0cb72 100644 --- a/src/rootmenu.c +++ b/src/rootmenu.c @@ -1359,8 +1359,7 @@ static WMenu *readMenuDirectory(WScreen *scr, const char *title, char **path, co addMenuEntry(menu, M_(data->name), NULL, "OPEN_MENU", buffer, path[data->index]); wfree(buffer); - if (data->name) - wfree(data->name); + wfree(data->name); wfree(data); } @@ -1405,8 +1404,7 @@ static WMenu *readMenuDirectory(WScreen *scr, const char *title, char **path, co addMenuEntry(menu, M_(data->name), NULL, "SHEXEC", buffer, path[data->index]); wfree(buffer); - if (data->name) - wfree(data->name); + wfree(data->name); wfree(data); } http://repo.or.cz/w/wmaker-crm.git/commit/5cc3f0d0bffc4db75ae5509aeed6d476cadfc79e commit 5cc3f0d0bffc4db75ae5509aeed6d476cadfc79e Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:48 2014 +0100 wmaker: make parsing on display name less prone to crash in SetupEnvironment (Coverity #50096) When creating the environment variable for the sub-process that wmaker can create, Coverity pointed that if was possible to crash if the name of the display did not contain the ':', which is probably ok in most case, but we can't be sure about what it could contain in special cases. This patch adds a proper check so, at least, it would not crash if the case were to arise. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/main.c b/src/main.c index 4c8ee9b3..67808039 100644 --- a/src/main.c +++ b/src/main.c @@ -246,9 +246,22 @@ void SetupEnvironment(WScreen * scr) int len = strlen(DisplayName) + 64; tmp = wmalloc(len); snprintf(tmp, len, "DISPLAY=%s", XDisplayName(DisplayName)); - ptr = strchr(strchr(tmp, ':'), '.'); - if (ptr) - *ptr = 0; + + /* Search from the end to be compatible with ipv6 address */ + ptr = strrchr(tmp, ':'); + if (ptr == NULL) { + static Bool message_already_displayed = False; + + if (!message_already_displayed) + wwarning(_("the display name has an unexpected syntax: "%s""), + XDisplayName(DisplayName)); + message_already_displayed = True; + } else { + /* If found, remove the screen specification from the display variable */ + ptr = strchr(ptr, '.'); + if (ptr) + *ptr = 0; + } snprintf(buf, sizeof(buf), ".%i", scr->screen); strcat(tmp, buf); putenv(tmp); http://repo.or.cz/w/wmaker-crm.git/commit/2a68274f29f3227705bd23841374d0e3966201b6 commit 2a68274f29f3227705bd23841374d0e3966201b6 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:47 2014 +0100 wmaker: fix incomplete null pointer check in wFrameWindowChangeTitle (Coverity #50058) As pointed by Coverity, despite the numerous null pointer checks there is still a case where one can pass trough and make wmaker crash. This patch simplifies it all but making only one check at the beginning so the code is safe and the remaining is simpler. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/framewin.c b/src/framewin.c index 13fe1e09..d045f63a 100644 --- a/src/framewin.c +++ b/src/framewin.c @@ -1205,12 +1205,12 @@ void wFrameWindowResize(WFrameWindow * fwin, int width, int height) int wFrameWindowChangeTitle(WFrameWindow *fwin, const char *new_title) { + if (new_title == NULL) + return 0; + /* check if the title is the same as before */ if (fwin->title) { - if (new_title && (strcmp(fwin->title, new_title) == 0)) - return 0; - } else { - if (!new_title) + if (strcmp(fwin->title, new_title) == 0) return 0; } http://repo.or.cz/w/wmaker-crm.git/commit/73da0c667b1cba5282c1c410734d90bf65e94f5d commit 73da0c667b1cba5282c1c410734d90bf65e94f5d Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:46 2014 +0100 wmaker: remove unnecessary null check (Coverity #50196) As pointed by Coverity, text cannot be null in this part of code. The analysis shows that if it were, the function wIconChangeImageFile would have directed execution to the 'else' branch. (and if it hadn't, the code would have crashed beforehand because 'strlen' does not like null pointers) Coverity recommends to remove the unnecessary check for code the maintainability. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/dockedapp.c b/src/dockedapp.c index 6812ed1c..44eaacda 100644 --- a/src/dockedapp.c +++ b/src/dockedapp.c @@ -170,8 +170,7 @@ static void panelBtnCallback(WMWidget * self, void *data) snprintf(buf, len, _("Could not open specified icon file: %s"), text); if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), buf, _("OK"), _("Ignore"), NULL) == WAPRDefault) { - if (text) - wfree(text); + wfree(text); wfree(buf); return; } http://repo.or.cz/w/wmaker-crm.git/commit/c6b59238fbfa0a7485bef5b3b994c5f11454e791 commit c6b59238fbfa0a7485bef5b3b994c5f11454e791 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:45 2014 +0100 wmaker: removed unnecessary variable 'done' in panelBtnCallback The variable is assigned a value that never change, so it adds extra complexity which is not good for code maintainability. It is probable that this was meant for cases that are handled in current code with early function return, which are better for code readability. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/dockedapp.c b/src/dockedapp.c index e7f0513d..6812ed1c 100644 --- a/src/dockedapp.c +++ b/src/dockedapp.c @@ -154,7 +154,6 @@ static void panelBtnCallback(WMWidget * self, void *data) WMButton *btn = self; AppSettingsPanel *panel = (AppSettingsPanel *) data; char *text; - int done = 1; if (panel->okBtn == btn) { text = WMGetTextFieldText(panel->iconField); @@ -215,8 +214,7 @@ static void panelBtnCallback(WMWidget * self, void *data) panel->editedIcon->lock = WMGetButtonSelected(panel->lockBtn); } - if (done) - DestroyDockAppSettingsPanel(panel); + DestroyDockAppSettingsPanel(panel); } #define PWIDTH 295 http://repo.or.cz/w/wmaker-crm.git/commit/9860880279eda57fb8fc13148f93b046e02c7a63 commit 9860880279eda57fb8fc13148f93b046e02c7a63 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:44 2014 +0100 wmaker: removed unnecessary null pointer check (Coverity #50041) As pointed by Coverity, the 'cmd' is checked for null at the beginning of the function, so the second case to handle the null pointer is not needed. This also means that 'command' cannot be null (wstrdup never returns null) so the code can also be simplified. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/dock.c b/src/dock.c index bf6abd24..2b8925b2 100644 --- a/src/dock.c +++ b/src/dock.c @@ -1659,14 +1659,11 @@ static WAppIcon *restore_icon_state(WScreen *scr, WMPropList *info, int type, in return NULL; /* get commands */ - if (cmd) - command = wstrdup(WMGetFromPLString(cmd)); - else - command = NULL; + command = wstrdup(WMGetFromPLString(cmd)); + + if (strcmp(command, "-") == 0) { + wfree(command); - if (!command || strcmp(command, "-") == 0) { - if (command) - wfree(command); if (wclass) wfree(wclass); if (winstance) @@ -1680,8 +1677,8 @@ static WAppIcon *restore_icon_state(WScreen *scr, WMPropList *info, int type, in wfree(wclass); if (winstance) wfree(winstance); - if (command) - wfree(command); + + wfree(command); aicon->icon->core->descriptor.handle_mousedown = iconMouseDown; aicon->icon->core->descriptor.handle_enternotify = clipEnterNotify; http://repo.or.cz/w/wmaker-crm.git/commit/ca5ec118f0ce84ab8d653953f6fb598858728513 commit ca5ec118f0ce84ab8d653953f6fb598858728513 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:43 2014 +0100 wmaker: improve error messages when trying to start the helper Try to provide better messages to understand what went wrong, including more information, and made them translatable; Changed the call to 'dup' into 'dup2' which has a safer behaviour because we can specify the target descriptor we want; Removed a few check for the 'close()' because in these cases we do not really care if they fail (we can't do anything about it and it just adds noise in the logs). Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/misc.c b/src/misc.c index 5d54561a..b4c71023 100644 --- a/src/misc.c +++ b/src/misc.c @@ -33,6 +33,7 @@ #include <pwd.h> #include <math.h> #include <time.h> +#include <errno.h> #include <X11/XKBlib.h> @@ -929,48 +930,51 @@ Bool start_bg_helper(WScreen *scr) int filedes[2]; if (pipe(filedes) < 0) { - werror("pipe() failed:can't set workspace specific background image"); + werror(_("%s failed, can't set workspace specific background image (%s)"), + "pipe()", strerror(errno)); return False; } pid = fork(); if (pid < 0) { - werror("fork() failed:can't set workspace specific background image"); - if (close(filedes[0]) < 0) - werror("could not close pipe"); - if (close(filedes[1]) < 0) - werror("could not close pipe"); + werror(_("%s failed, can't set workspace specific background image (%s)"), + "fork()", strerror(errno)); + close(filedes[0]); + close(filedes[1]); return False; } else if (pid == 0) { - char *dither; + const char *dither; /* We don't need this side of the pipe in the child process */ close(filedes[1]); SetupEnvironment(scr); - if (close(0) < 0) - werror("could not close pipe"); - if (dup(filedes[0]) < 0) { - werror("dup() failed:can't set workspace specific background image"); + close(STDIN_FILENO); + if (dup2(filedes[0], STDIN_FILENO) < 0) { + werror(_("%s failed, can't set workspace specific background image (%s)"), + "dup2()", strerror(errno)); + exit(1); } close(filedes[0]); + dither = wPreferences.no_dithering ? "-m" : "-d"; if (wPreferences.smooth_workspace_back) execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL); else execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL); - werror("could not execute wmsetbg"); + + werror(_("could not execute "%s": %s"), "wmsetbg", strerror(errno)); exit(1); } else { /* We don't need this side of the pipe in the parent process */ close(filedes[0]); - if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) { - werror("error setting close-on-exec flag"); - } + if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) + wwarning(_("could not set close-on-exec flag for bg_helper's communication file handle (%s)"), + strerror(errno)); scr->helper_fd = filedes[1]; scr->helper_pid = pid; http://repo.or.cz/w/wmaker-crm.git/commit/5f5dc351bdecaa2f61a88ae6c376947a95bd6daa commit 5f5dc351bdecaa2f61a88ae6c376947a95bd6daa Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:42 2014 +0100 wmaker: close unneeded file handles when running the bg helper (Coverity #50137) As pointed by Coverity, the file descriptor used in 'dup' to become the child process's STDIN is leaked, because it will not be used anymore, so we close it after the dup. Similarly, the file descriptors that represent the other ends of the pipe for each process are useless, so let's close them too to keep a reasonable number of opened file descriptors over time. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/misc.c b/src/misc.c index 096052ac..5d54561a 100644 --- a/src/misc.c +++ b/src/misc.c @@ -945,6 +945,9 @@ Bool start_bg_helper(WScreen *scr) } else if (pid == 0) { char *dither; + /* We don't need this side of the pipe in the child process */ + close(filedes[1]); + SetupEnvironment(scr); if (close(0) < 0) @@ -952,6 +955,7 @@ Bool start_bg_helper(WScreen *scr) if (dup(filedes[0]) < 0) { werror("dup() failed:can't set workspace specific background image"); } + close(filedes[0]); dither = wPreferences.no_dithering ? "-m" : "-d"; if (wPreferences.smooth_workspace_back) execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL); @@ -961,9 +965,9 @@ Bool start_bg_helper(WScreen *scr) exit(1); } else { - if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) { - werror("error setting close-on-exec flag"); - } + /* We don't need this side of the pipe in the parent process */ + close(filedes[0]); + if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) { werror("error setting close-on-exec flag"); } http://repo.or.cz/w/wmaker-crm.git/commit/179748887ee724ceb24153ba55437217b396a828 commit 179748887ee724ceb24153ba55437217b396a828 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:41 2014 +0100 wmaker: moved the code for the bg helper to a dedicated function In order to make code easier to maintain, the code related to creating the Helper process (which helps by setting the background of the workspace) is moved to a dedicated function, which have been moved to the same location as the function for communicating with the helper. Took opportunity to de-CamelCase the related names. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/defaults.c b/src/defaults.c index b069d084..a4b8261a 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -32,7 +32,6 @@ #include <time.h> #include <sys/types.h> #include <sys/stat.h> -#include <fcntl.h> #include <limits.h> #include <signal.h> @@ -62,7 +61,6 @@ #include "workspace.h" #include "properties.h" #include "misc.h" -#include "event.h" #include "winmenu.h" #define MAX_SHORTCUT_LENGTH 32 @@ -2970,20 +2968,6 @@ static int setFrameSelectedBorderColor(WScreen * scr, WDefaultEntry * entry, voi return REFRESH_FRAME_BORDER; } -static void trackDeadProcess(pid_t pid, unsigned int status, void *client_data) -{ - WScreen *scr = (WScreen *) client_data; - - /* Parameter not used, but tell the compiler that it is ok */ - (void) pid; - (void) status; - - close(scr->helper_fd); - scr->helper_fd = 0; - scr->helper_pid = 0; - scr->flags.backimage_helper_launched = 0; -} - static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void *tdata, void *bar) { WMPropList *value = tdata; @@ -3004,62 +2988,15 @@ static int setWorkspaceSpecificBack(WScreen * scr, WDefaultEntry * entry, void * return 0; } } else { - pid_t pid; - int filedes[2]; - if (WMGetPropListItemCount(value) == 0) return 0; - if (pipe(filedes) < 0) { - werror("pipe() failed:can't set workspace specific background image"); - + if (!start_bg_helper(scr)) { WMReleasePropList(value); return 0; } - pid = fork(); - if (pid < 0) { - werror("fork() failed:can't set workspace specific background image"); - if (close(filedes[0]) < 0) - werror("could not close pipe"); - if (close(filedes[1]) < 0) - werror("could not close pipe"); - - } else if (pid == 0) { - char *dither; - - SetupEnvironment(scr); - - if (close(0) < 0) - werror("could not close pipe"); - if (dup(filedes[0]) < 0) { - werror("dup() failed:can't set workspace specific background image"); - } - dither = wPreferences.no_dithering ? "-m" : "-d"; - if (wPreferences.smooth_workspace_back) - execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL); - else - execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL); - werror("could not execute wmsetbg"); - exit(1); - } else { - - if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) { - werror("error setting close-on-exec flag"); - } - if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) { - werror("error setting close-on-exec flag"); - } - - scr->helper_fd = filedes[1]; - scr->helper_pid = pid; - scr->flags.backimage_helper_launched = 1; - - wAddDeathHandler(pid, trackDeadProcess, scr); - - SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path); - } - + SendHelperMessage(scr, 'P', -1, wPreferences.pixmap_path); } for (i = 0; i < WMGetPropListItemCount(value); i++) { diff --git a/src/misc.c b/src/misc.c index 26348d40..096052ac 100644 --- a/src/misc.c +++ b/src/misc.c @@ -28,6 +28,7 @@ #include <string.h> #include <strings.h> #include <unistd.h> +#include <fcntl.h> #include <stdarg.h> #include <pwd.h> #include <math.h> @@ -49,6 +50,8 @@ #include "dialog.h" #include "xutil.h" #include "xmodifier.h" +#include "main.h" +#include "event.h" #define ICON_SIZE wPreferences.icon_size @@ -906,6 +909,75 @@ static void UnescapeWM_CLASS(const char *str, char **name, char **class) } } +static void track_bg_helper_death(pid_t pid, unsigned int status, void *client_data) +{ + WScreen *scr = (WScreen *) client_data; + + /* Parameter not used, but tell the compiler that it is ok */ + (void) pid; + (void) status; + + close(scr->helper_fd); + scr->helper_fd = 0; + scr->helper_pid = 0; + scr->flags.backimage_helper_launched = 0; +} + +Bool start_bg_helper(WScreen *scr) +{ + pid_t pid; + int filedes[2]; + + if (pipe(filedes) < 0) { + werror("pipe() failed:can't set workspace specific background image"); + return False; + } + + pid = fork(); + if (pid < 0) { + werror("fork() failed:can't set workspace specific background image"); + if (close(filedes[0]) < 0) + werror("could not close pipe"); + if (close(filedes[1]) < 0) + werror("could not close pipe"); + return False; + + } else if (pid == 0) { + char *dither; + + SetupEnvironment(scr); + + if (close(0) < 0) + werror("could not close pipe"); + if (dup(filedes[0]) < 0) { + werror("dup() failed:can't set workspace specific background image"); + } + dither = wPreferences.no_dithering ? "-m" : "-d"; + if (wPreferences.smooth_workspace_back) + execlp("wmsetbg", "wmsetbg", "-helper", "-S", dither, NULL); + else + execlp("wmsetbg", "wmsetbg", "-helper", dither, NULL); + werror("could not execute wmsetbg"); + exit(1); + + } else { + if (fcntl(filedes[0], F_SETFD, FD_CLOEXEC) < 0) { + werror("error setting close-on-exec flag"); + } + if (fcntl(filedes[1], F_SETFD, FD_CLOEXEC) < 0) { + werror("error setting close-on-exec flag"); + } + + scr->helper_fd = filedes[1]; + scr->helper_pid = pid; + scr->flags.backimage_helper_launched = 1; + + wAddDeathHandler(pid, track_bg_helper_death, scr); + + return True; + } +} + void SendHelperMessage(WScreen *scr, char type, int workspace, const char *msg) { char *buffer; diff --git a/src/misc.h b/src/misc.h index 74e02ac3..36f08a0e 100644 --- a/src/misc.h +++ b/src/misc.h @@ -33,6 +33,9 @@ void move_window(Window win, int from_x, int from_y, int to_x, int to_y); void SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y); void SlideWindows(Window *wins[], int n, int from_x, int from_y, int to_x, int to_y); void ParseWindowName(WMPropList *value, char **winstance, char **wclass, const char *where); + +/* Helper is a 'wmsetbg' subprocess with sets the background for the current workspace */ +Bool start_bg_helper(WScreen *scr); void SendHelperMessage(WScreen *scr, char type, int workspace, const char *msg); char *ShrinkString(WMFont *font, const char *string, int width); http://repo.or.cz/w/wmaker-crm.git/commit/34435563e7d7f2c4b6d54a96e5dada635b1aba32 commit 34435563e7d7f2c4b6d54a96e5dada635b1aba32 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:40 2014 +0100 wmaker: minor fixes for the size of an aperçu There was a probable bug when reading settings, because the function used was 'getInt' which would try to store the result in a 'char'. As it would be probably easier for user to have the value directly in pixels, the storage is now done in an int so there won't be problem anymore. Changed the behaviour of the constant APERCU_BORDER, which would be assumed to be the size of the border in pixel, but in previous code it was actually the sum of the two border (1 on each side). All maths have been changed to have it as a single border width. Took opportunity to group variable assignation for titleHeight and shortenTitle in a single place, because it is not convenient to have them spread around (one value in the beginning and others later in the code) and using default values prevents some checks that modern compiler can do to help produce safer code. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 17462f8f..0663b546 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -444,7 +444,7 @@ extern struct WPreferences { char cycle_ignore_minimized; /* Ignore minimized windows when cycling */ char strict_windoze_cycle; /* don't close switch panel when shift is released */ char panel_only_open; /* Only open the switch panel; don't switch */ - char apercu_size; /* Size of apercu preview as a multiple of icon size */ + int apercu_size; /* Size of apercu preview in pixels */ /* All delays here are in ms. 0 means instant auto-action. */ int clip_auto_raise_delay; /* Delay after which the clip will be raised when entered */ diff --git a/src/balloon.c b/src/balloon.c index de003aad..c989803e 100644 --- a/src/balloon.c +++ b/src/balloon.c @@ -376,26 +376,33 @@ static void showText(WScreen *scr, int x, int y, int h, int w, const char *text) } #endif /* !SHAPED_BALLOON */ -static void showApercu(WScreen *scr, int x, int y, int height, int width, char *title, Pixmap apercu) +static void showApercu(WScreen *scr, int x, int y, const char *title, Pixmap apercu) { Pixmap pixmap; WMFont *font = scr->info_text_font; - int titleHeight = 0; - char *shortenTitle = title; + int width, height; + int titleHeight; + char *shortenTitle; if (scr->balloon->contents) XFreePixmap(dpy, scr->balloon->contents); + width = wPreferences.apercu_size; + height = wPreferences.apercu_size; + if (wPreferences.miniwin_title_balloon) { - shortenTitle = ShrinkString(font, title, width - APERCU_BORDER); + shortenTitle = ShrinkString(font, title, width - APERCU_BORDER * 2); titleHeight = countLines(shortenTitle) * WMFontHeight(font) + 4; height += titleHeight; + } else { + shortenTitle = NULL; + titleHeight = 0; } if (x < 0) x = 0; else if (x + width > scr->scr_width - 1) - x = scr->scr_width - width - APERCU_BORDER; + x = scr->scr_width - width - 1; if (y - height - 2 < 0) { y += wPreferences.icon_size; @@ -413,16 +420,16 @@ static void showApercu(WScreen *scr, int x, int y, int height, int width, char * pixmap = XCreatePixmap(dpy, scr->root_win, width, height, scr->w_depth); XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width, height); - if (shortenTitle && wPreferences.miniwin_title_balloon) { + if (shortenTitle != NULL) { drawMultiLineString(scr->wmscreen, pixmap, scr->window_title_color[0], font, APERCU_BORDER, APERCU_BORDER, shortenTitle, strlen(shortenTitle)); wfree(shortenTitle); } XCopyArea(dpy, apercu, pixmap, scr->draw_gc, - 0, 0, (wPreferences.icon_size - 1 - APERCU_BORDER) * wPreferences.apercu_size, - (wPreferences.icon_size - 1 - APERCU_BORDER) * wPreferences.apercu_size, - APERCU_BORDER, APERCU_BORDER + titleHeight); + 0, 0, (wPreferences.apercu_size - 1 - APERCU_BORDER * 2), + (wPreferences.apercu_size - 1 - APERCU_BORDER * 2), + APERCU_BORDER, APERCU_BORDER + titleHeight); #ifdef SHAPED_BALLOON XShapeCombineMask(dpy, scr->balloon->window, ShapeBounding, 0, 0, None, ShapeSet); @@ -457,9 +464,7 @@ static void showBalloon(WScreen *scr) if (wPreferences.miniwin_apercu_balloon && scr->balloon->apercu != None) /* used to display either the apercu alone or the apercu and the title */ - showApercu(scr, x, y, (wPreferences.icon_size - 1) * wPreferences.apercu_size, - (wPreferences.icon_size - 1) * wPreferences.apercu_size, - scr->balloon->text, scr->balloon->apercu); + showApercu(scr, x, y, scr->balloon->text, scr->balloon->apercu); else showText(scr, x, y, scr->balloon->h, w, scr->balloon->text); } diff --git a/src/defaults.c b/src/defaults.c index cf344246..b069d084 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -1181,6 +1181,21 @@ void wReadDefaults(WScreen * scr, WMPropList * new_dict) } } + /* + * Backward Compatibility: + * the option 'apercu_size' used to be coded as a multiple of the icon size in v0.95.6 + * it is now expressed directly in pixels, but to avoid breaking user's setting we check + * for old coding and convert it now. + * This code should probably stay for at least 2 years, you should not consider removing + * it before year 2017 + */ + if (wPreferences.apercu_size < 24) { + /* 24 is the minimum icon size proposed in WPref's settings */ + wPreferences.apercu_size *= wPreferences.icon_size; + wwarning(_("your ApercuSize setting is using old syntax, it is converted to %d pixels; consider running WPrefs.app to update your settings"), + wPreferences.apercu_size); + } + if (needs_refresh != 0 && !scr->flags.startup) { int foo; diff --git a/src/icon.c b/src/icon.c index d8265b52..75f5293e 100644 --- a/src/icon.c +++ b/src/icon.c @@ -593,8 +593,8 @@ void set_icon_apercu(WIcon *icon, RImage *image) RImage *scaled_apercu; WScreen *scr = icon->core->screen_ptr; - scaled_apercu = RSmoothScaleImage(image, (wPreferences.icon_size - 1 - APERCU_BORDER) * wPreferences.apercu_size, - (wPreferences.icon_size - 1 - APERCU_BORDER) * wPreferences.apercu_size); + scaled_apercu = RSmoothScaleImage(image, wPreferences.apercu_size - 2 * APERCU_BORDER, + wPreferences.apercu_size - 2 * APERCU_BORDER); if (RConvertImage(scr->rcontext, scaled_apercu, &tmp)) { if (icon->apercu != None) diff --git a/src/icon.h b/src/icon.h index af82f5c2..80e9acf9 100644 --- a/src/icon.h +++ b/src/icon.h @@ -29,7 +29,8 @@ #define TILE_CLIP 1 #define TILE_DRAWER 2 -#define APERCU_BORDER 2 +/* This is the border, in pixel, drawn around an Aperçu */ +#define APERCU_BORDER 1 typedef struct WIcon { WCoreWindow *core; http://repo.or.cz/w/wmaker-crm.git/commit/6ee2760673821f1b9b03a4c4224121c15299215e commit 6ee2760673821f1b9b03a4c4224121c15299215e Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:39 2014 +0100 wmaker: removed unnecessary assignation (Coverity #50257) As pointed by Coverity, the return value is saved into a variable, but this value is never used. As the variable is re-used afterwards, this assignation could mislead on what is done, so for code maintainability the value is just ignored. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/client.c b/src/client.c index fe9a64ae..99ed445c 100644 --- a/src/client.c +++ b/src/client.c @@ -574,6 +574,7 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event) if (foo->fake_group && foo->fake_group == fPtr) { WSETUFLAG(foo, shared_appicon, 0); foo->fake_group = NULL; + if (foo->group_id != None) foo->main_window = foo->group_id; else if (foo->client_leader != None) @@ -582,9 +583,9 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event) foo->main_window = foo->client_win; else foo->main_window = None; - if (foo->main_window) { - wapp = wApplicationCreate(foo); - } + + if (foo->main_window) + wApplicationCreate(foo); } foo = foo->prev; } http://repo.or.cz/w/wmaker-crm.git/commit/36d95195eb76ab80e7880b8ad4fbea53a5d0bdb8 commit 36d95195eb76ab80e7880b8ad4fbea53a5d0bdb8 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:38 2014 +0100 wmaker: removed unnecessary check when painting application icon (Coverity #50052) As pointed by Coverity, there was a check for null pointer on scr->dock_dots, but this check was not made in the 2nd use of it, done if the HIDDENDOT feature was enabled. Investigation show that it is not possible that this pointer could be created NULL, so let's remove the unneeded check. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/appicon.c b/src/appicon.c index 524fded7..1d28a245 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -411,7 +411,7 @@ void wAppIconPaint(WAppIcon *aicon) if (aicon->docked && scr->dock && scr->dock == aicon->dock && aicon->yindex == 0) updateDockNumbers(scr); # endif - if (scr->dock_dots && aicon->docked && !aicon->running && aicon->command != NULL) { + if (aicon->docked && !aicon->running && aicon->command != NULL) { XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask); XSetClipOrigin(dpy, scr->copy_gc, 0, 0); XCopyArea(dpy, scr->dock_dots->image, aicon->icon->core->window, http://repo.or.cz/w/wmaker-crm.git/commit/30d85a007b60d775544d936d7f31b150685f05e3 commit 30d85a007b60d775544d936d7f31b150685f05e3 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:37 2014 +0100 WMaker: Fixed crash if the RContext creation fail on a Screen (Coverity #50066) As pointed by Coverity, it is possible that RCreateContext fails for more reasons that were handled by wScreenInit, so we provide an error message for the other cases along with cleaner return from function. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/screen.c b/src/screen.c index 36943fbd..51e23178 100644 --- a/src/screen.c +++ b/src/screen.c @@ -577,6 +577,11 @@ WScreen *wScreenInit(int screen_number) scr->rcontext = RCreateContext(dpy, screen_number, &rattr); } + if (scr->rcontext == NULL) { + wfatal(_("can't create Context on screen %d, %s"), + screen_number, RMessageForError(RErrorCode)); + goto abort_no_context; + } scr->w_win = scr->rcontext->drawable; scr->w_visual = scr->rcontext->visual; @@ -589,6 +594,7 @@ WScreen *wScreenInit(int screen_number) if (!scr->wmscreen) { wfatal(_("could not initialize WINGs widget set")); RDestroyContext(scr->rcontext); + abort_no_context: WMFreeArray(scr->fakeGroupLeaders); wfree(scr->totalUsableArea); wfree(scr->usableArea); http://repo.or.cz/w/wmaker-crm.git/commit/ba06d2683f2b9319c85874f6e8c5e2355088903b commit ba06d2683f2b9319c85874f6e8c5e2355088903b Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:36 2014 +0100 wmaker: avoid allocating temporary memory in GetShortcutKey (Coverity #50115) As pointed by Coverity, the function GetShortcutKey was allocating memory for temporary operation, and did not free it in the end. Because it participates in memory fragmentation and it is not really efficient, this patch removes the allocation and uses a local storage on the stack, and replaces wstrappend in favour of a fast string build. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/misc.c b/src/misc.c index f3ff5438..26348d40 100644 --- a/src/misc.c +++ b/src/misc.c @@ -761,21 +761,43 @@ char *GetShortcutString(const char *shortcut) char *GetShortcutKey(WShortKey key) { - char *tmp = NULL; - char *k = XKeysymToString(XkbKeycodeToKeysym(dpy, key.keycode, 0, 0)); - if (!k) return NULL; - - char **m = wPreferences.modifier_labels; - if (key.modifier & ControlMask) tmp = wstrappend(tmp, m[1] ? m[1] : "Control+"); - if (key.modifier & ShiftMask) tmp = wstrappend(tmp, m[0] ? m[0] : "Shift+"); - if (key.modifier & Mod1Mask) tmp = wstrappend(tmp, m[2] ? m[2] : "Mod1+"); - if (key.modifier & Mod2Mask) tmp = wstrappend(tmp, m[3] ? m[3] : "Mod2+"); - if (key.modifier & Mod3Mask) tmp = wstrappend(tmp, m[4] ? m[4] : "Mod3+"); - if (key.modifier & Mod4Mask) tmp = wstrappend(tmp, m[5] ? m[5] : "Mod4+"); - if (key.modifier & Mod5Mask) tmp = wstrappend(tmp, m[6] ? m[6] : "Mod5+"); - tmp = wstrappend(tmp, k); - - return GetShortcutString(tmp); + const char *key_name; + char buffer[256]; + char *wr; + + void append_string(const char *string) + { + while (*string) { + if (wr >= buffer + sizeof(buffer) - 1) + break; + *wr++ = *string++; + } + } + + void append_modifier(int modifier_index, const char *fallback_name) + { + if (wPreferences.modifier_labels[modifier_index]) + append_string(wPreferences.modifier_labels[modifier_index]); + else + append_string(fallback_name); + } + + key_name = XKeysymToString(XkbKeycodeToKeysym(dpy, key.keycode, 0, 0)); + if (!key_name) + return NULL; + + wr = buffer; + if (key.modifier & ControlMask) append_modifier(1, "Control+"); + if (key.modifier & ShiftMask) append_modifier(0, "Shift+"); + if (key.modifier & Mod1Mask) append_modifier(2, "Mod1+"); + if (key.modifier & Mod2Mask) append_modifier(3, "Mod2+"); + if (key.modifier & Mod3Mask) append_modifier(4, "Mod3+"); + if (key.modifier & Mod4Mask) append_modifier(5, "Mod4+"); + if (key.modifier & Mod5Mask) append_modifier(6, "Mod5+"); + append_string(key_name); + *wr = '0'; + + return GetShortcutString(buffer); } char *EscapeWM_CLASS(const char *name, const char *class) http://repo.or.cz/w/wmaker-crm.git/commit/e602ac87680e7ec6940ab82d9b805d828367a14a commit e602ac87680e7ec6940ab82d9b805d828367a14a Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:35 2014 +0100 wmaker: replaced dangerous function type conversion by argument conversion A type conversion applied to a function when used as a pointer is dangerous because the compiler may not be able to make sure arguments will be compatible across architectures, so it can crash the application. This is replaced by a function prototype matching exactly what is expected for the callback, and have the type conversion on the argument done inside the function so the compiler have complete liberty to generate any code needed to handle it safely. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/src/menu.c b/src/menu.c index d23f3b3c..e573b395 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1543,8 +1543,10 @@ typedef struct _delay { int ox, oy; } _delay; -static void leaving(_delay * dl) +static void callback_leaving(void *user_param) { + _delay *dl = (_delay *) user_param; + wMenuMove(dl->menu, dl->ox, dl->oy, True); dl->menu->jump_back = NULL; dl->menu->menu->screen_ptr->flags.jump_back_pending = 0; @@ -1652,6 +1654,7 @@ void wMenuScroll(WMenu *menu) if (jump_back) { _delay *delayer; + if (!omenu->jump_back) { delayer = wmalloc(sizeof(_delay)); delayer->menu = omenu; @@ -1661,7 +1664,7 @@ void wMenuScroll(WMenu *menu) scr->flags.jump_back_pending = 1; } else delayer = omenu->jump_back; - WMAddTimerHandler(MENU_JUMP_BACK_DELAY, (WMCallback *) leaving, delayer); + WMAddTimerHandler(MENU_JUMP_BACK_DELAY, callback_leaving, delayer); } } http://repo.or.cz/w/wmaker-crm.git/commit/8dcfd3568a4e6d207a400d7d0860cebd1d9586b4 commit 8dcfd3568a4e6d207a400d7d0860cebd1d9586b4 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:34 2014 +0100 WINGs: fix possible null pointer dereference in W_RealizeView (Coverity #50060) As pointed by Coverity, the function makes use of a pointer which may be null, so we have to properly check that to ensure application will not crash. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wview.c b/WINGs/wview.c index 1138f367..20662447 100644 --- a/WINGs/wview.c +++ b/WINGs/wview.c @@ -188,6 +188,12 @@ void W_RealizeView(W_View * view) } if (!view->flags.realized) { + + if (view->parent == NULL) { + wwarning("trying to realize widget without parent"); + return; + } + parentWID = view->parent->window; view->window = XCreateWindow(dpy, parentWID, view->pos.x, view->pos.y, view->size.width, view->size.height, 0, http://repo.or.cz/w/wmaker-crm.git/commit/4a857f18d0cb74cdb183e821c1246ae9fd21da16 commit 4a857f18d0cb74cdb183e821c1246ae9fd21da16 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:33 2014 +0100 WINGs: removed unnecessary size checks in WMGetBrowserPaths The function is building strings from the directory names into an allocated buffer, but the function took time first to calculate the exact size needed for the resulting string, so the check on wstrlcat's result will never fail. As we still use wstrlcat it is not possible to overrun the buffer, we would just return a truncated string in the list instead of return no list at all but the case where it would happen is impossible. This should fix Coverity #50111 (Resource leak) which was present in the code of one of the related early return. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wbrowser.c b/WINGs/wbrowser.c index 4027c2e6..04756113 100644 --- a/WINGs/wbrowser.c +++ b/WINGs/wbrowser.c @@ -781,11 +781,7 @@ WMArray *WMGetBrowserPaths(WMBrowser * bPtr) path = wmalloc(slen); /* ignore first `/' */ for (i = 0; i <= column; i++) { - if (wstrlcat(path, bPtr->pathSeparator, slen) >= slen) { - wfree(path); - WMFreeArray(paths); - return NULL; - } + wstrlcat(path, bPtr->pathSeparator, slen); if (i == column) { item = lastItem; } else { @@ -793,10 +789,7 @@ WMArray *WMGetBrowserPaths(WMBrowser * bPtr) } if (!item) break; - if (wstrlcat(path, item->text, slen) >= slen) { - wfree(path); - return NULL; - } + wstrlcat(path, item->text, slen); } WMAddToArray(paths, path); } http://repo.or.cz/w/wmaker-crm.git/commit/ec1660dc499b33a2311888ccee6aa73c95de78ca commit ec1660dc499b33a2311888ccee6aa73c95de78ca Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:32 2014 +0100 WINGs: inverted the direction for mouse wheel on WMSliders The original choice may have looked mathematically correct, but it was actually counter-intuitive and opposite to what every other application do with sliders. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/wslider.c b/WINGs/wslider.c index a18987a0..cacf57ca 100644 --- a/WINGs/wslider.c +++ b/WINGs/wslider.c @@ -410,16 +410,16 @@ static void handleActionEvents(XEvent * event, void *data) switch (event->type) { case ButtonPress: - if (event->xbutton.button == WINGsConfiguration.mouseWheelUp && !sPtr->flags.dragging) { - /* Wheel up */ + if (event->xbutton.button == WINGsConfiguration.mouseWheelDown && !sPtr->flags.dragging) { + /* Wheel down */ if (sPtr->value + 1 <= sPtr->maxValue) { WMSetSliderValue(sPtr, sPtr->value + 1); if (sPtr->flags.continuous && sPtr->action) { (*sPtr->action) (sPtr, sPtr->clientData); } } - } else if (event->xbutton.button == WINGsConfiguration.mouseWheelDown && !sPtr->flags.dragging) { - /* Wheel down */ + } else if (event->xbutton.button == WINGsConfiguration.mouseWheelUp && !sPtr->flags.dragging) { + /* Wheel up */ if (sPtr->value - 1 >= sPtr->minValue) { WMSetSliderValue(sPtr, sPtr->value - 1); if (sPtr->flags.continuous && sPtr->action) { http://repo.or.cz/w/wmaker-crm.git/commit/1f2dd583bee10399a86dc636286e4dd7e6ad376b commit 1f2dd583bee10399a86dc636286e4dd7e6ad376b Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:31 2014 +0100 WUtil: fix default rights for file created when saving PropList When creating the temporary file that will become the final file if no problem occurs, there is a chmod done which does not give write access to the group and to the others, but this is the task of the user-set umask. This patch makes the rights to everything (except execution, of course) and still applies the umask, so in the end the file will have the rights that user wants. Took the opportunity to make a little change related to the umask: it seems that some version of mkstemp have a security issue, which is in not a problem in our use case, but Coverity reports it (#50201) so as it does not cost anything, the patch also fixes it with an appropriate comment to explain the situation. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/proplist.c b/WINGs/proplist.c index 174edbe3..28a3ae26 100644 --- a/WINGs/proplist.c +++ b/WINGs/proplist.c @@ -1645,13 +1645,22 @@ Bool WMWritePropListToFile(WMPropList * plist, const char *path) thePath = wstrconcat(path, ".XXXXXX"); #ifdef HAVE_MKSTEMP + /* + * We really just want to read the current umask, but as Coverity is + * pointing a possible security issue: + * some versions of mkstemp do not set file rights properly on the + * created file, so it is recommended so set the umask beforehand. + * As we need to set an umask to read the current value, we take this + * opportunity to set a temporary aggresive umask so Coverity won't + * complain, even if we do not really care in the present use case. + */ + mask = umask(S_IRWXG | S_IRWXO); if ((fd = mkstemp(thePath)) < 0) { werror(_("mkstemp (%s) failed"), thePath); goto failure; } - mask = umask(0); umask(mask); - fchmod(fd, 0644 & ~mask); + fchmod(fd, 0666 & ~mask); if ((theFile = fdopen(fd, "wb")) == NULL) { close(fd); } http://repo.or.cz/w/wmaker-crm.git/commit/3e1ef70248298e14efb9458843ade4355f103e67 commit 3e1ef70248298e14efb9458843ade4355f103e67 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:30 2014 +0100 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.cu...@free.fr> diff --git a/WINGs/findfile.c b/WINGs/findfile.c index 21ed7e22..b5f1b1f0 100644 --- a/WINGs/findfile.c +++ b/WINGs/findfile.c @@ -23,7 +23,9 @@ #include "WUtil.h" +#include <sys/types.h> #include <sys/stat.h> +#include <fcntl.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -422,60 +424,104 @@ char *wfindfileinarray(WMPropList *array, const char *file) return NULL; } -int wcopy_file(const char *dir, const char *src_file, const char *dest_file) +int wcopy_file(const char *dest_dir, const char *src_file, const char *dest_file) { - FILE *src, *dst; - size_t nread, nwritten; - char *dstpath; - struct stat st; - char buf[4096]; - - /* only to a directory */ - if (stat(dir, &st) != 0 || !S_ISDIR(st.st_mode)) - return -1; - /* only copy files */ - if (stat(src_file, &st) != 0 || !S_ISREG(st.st_mode)) + char *path_dst; + int fd_src, fd_dst; + struct stat stat_src; + mode_t permission_dst; + const size_t buffer_size = 2 * 1024 * 1024; /* 4MB is a decent start choice to allow the OS to take advantage of modern disk's performance */ + char *buffer; /* The buffer is not created on the stack to avoid possible stack overflow as our buffer is big */ + + try_again_src: + fd_src = open(src_file, O_RDONLY | O_NOFOLLOW); + if (fd_src == -1) { + if (errno == EINTR) + goto try_again_src; + werror(_("Could not open input file "%s": %s"), src_file, strerror(errno)); return -1; + } - do { - src = fopen(src_file, "rb"); - } while ((src == NULL) && (errno == EINTR)); - if (src == NULL) { - werror(_("Could not open input file "%s""), src_file); + /* Only accept to copy regular files */ + if (fstat(fd_src, &stat_src) != 0 || !S_ISREG(stat_src.st_mode)) { + close(fd_src); return -1; } - dstpath = wstrconcat(dir, dest_file); - do { - dst = fopen(dstpath, "wb"); - } while ((dst == NULL) && (errno == EINTR)); - if (dst == NULL) { - werror(_("Could not create target file "%s""), dstpath); - wfree(dstpath); - fclose(src); + path_dst = wstrconcat(dest_dir, dest_file); + try_again_dst: + fd_dst = open(path_dst, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); + if (fd_dst == -1) { + if (errno == EINTR) + goto try_again_dst; + werror(_("Could not create target file "%s": %s"), path_dst, strerror(errno)); + wfree(path_dst); + close(fd_src); return -1; } - do { - nread = fread(buf, 1, sizeof(buf), src); - if (ferror(src)) - break; + buffer = malloc(buffer_size); /* Don't use wmalloc to avoid the memset(0) we don't need */ + if (buffer == NULL) { + werror(_("could not allocate memory for the copy buffer")); + close(fd_dst); + goto cleanup_and_return_failure; + } - nwritten = fwrite(buf, 1, nread, dst); - if (ferror(dst) || feof(src) || nread != nwritten) - break; + for (;;) { + ssize_t size_data; + const char *write_ptr; + size_t write_remain; + + try_again_read: + size_data = read(fd_src, buffer, buffer_size); + if (size_data == 0) + break; /* End of File have been reached */ + if (size_data < 0) { + if (errno == EINTR) + goto try_again_read; + werror(_("could not read from file "%s": %s"), src_file, strerror(errno)); + close(fd_dst); + goto cleanup_and_return_failure; + } - } while (1); + write_ptr = buffer; + write_remain = size_data; + while (write_remain > 0) { + ssize_t write_done; + + try_again_write: + write_done = write(fd_dst, write_ptr, write_remain); + if (write_done < 0) { + if (errno == EINTR) + goto try_again_write; + werror(_("could not write data to file "%s": %s"), path_dst, strerror(errno)); + close(fd_dst); + goto cleanup_and_return_failure; + } + write_ptr += write_done; + write_remain -= write_done; + } + } - if (ferror(src) || ferror(dst)) - unlink(dstpath); + /* Keep only the permission-related part of the field: */ + permission_dst = stat_src.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX); + if (fchmod(fd_dst, permission_dst) != 0) + wwarning(_("could not set permission 0%03o on file "%s": %s"), + permission_dst, path_dst, strerror(errno)); + + if (close(fd_dst) != 0) { + werror(_("could not close the file "%s": %s"), path_dst, strerror(errno)); + cleanup_and_return_failure: + free(buffer); + wfree(path_dst); + close(fd_src); + unlink(path_dst); + return -1; + } - fclose(src); - fchmod(fileno(dst), st.st_mode); - fsync(fileno(dst)); - if (fclose(dst)) - wwarning("error occured during fclose("%s")", dstpath); - wfree(dstpath); + free(buffer); + wfree(path_dst); + close(fd_src); return 0; } http://repo.or.cz/w/wmaker-crm.git/commit/0e5e36eb663fada470e1dfc9aadf62fa8669de06 commit 0e5e36eb663fada470e1dfc9aadf62fa8669de06 Author: Christophe CURIS <christophe.cu...@free.fr> Date: Sat Nov 15 19:40:29 2014 +0100 WUtil: changed order for null pointer check in array functions (Coverity #72806, #72807, #72819) As pointed by Coverity, there were some null pointer checks that had been misplaced, due to a pointer dereference present in a preceding check. This had been fixed by adding another null check in the check, making a duplicate check. This patch moves the null pointer check in first place, and remove the pointer check from the range check to separate the pointer check on one side and the range check on the other side. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> diff --git a/WINGs/array.c b/WINGs/array.c index 0b5be944..df52358d 100644 --- a/WINGs/array.c +++ b/WINGs/array.c @@ -126,11 +126,11 @@ void WMAddToArray(WMArray * array, void *item) void WMInsertInArray(WMArray * array, int index, void *item) { - wassertr(array && index >= 0 && index <= array->itemCount); - if (array == NULL) return; + wassertr(index >= 0 && index <= array->itemCount); + if (array->itemCount >= array->allocSize) { array->allocSize += RESIZE_INCREMENT; array->items = wrealloc(array->items, sizeof(void *) * array->allocSize); @@ -148,11 +148,11 @@ void *WMReplaceInArray(WMArray * array, int index, void *item) { void *old; - wassertrv(array && index >= 0 && index <= array->itemCount, NULL); - if (array == NULL) return NULL; + wassertrv(index >= 0 && index <= array->itemCount, NULL); + /* is it really useful to perform append if index == array->itemCount ? -Dan */ if (index == array->itemCount) { WMAddToArray(array, item); @@ -167,11 +167,11 @@ void *WMReplaceInArray(WMArray * array, int index, void *item) int WMDeleteFromArray(WMArray * array, int index) { - wassertrv(array && index >= 0 && index < array->itemCount, 0); - if (array == NULL) return 0; + wassertrv(index >= 0 && index < array->itemCount, 0); + if (array->destructor) { array->destructor(array->items[index]); } ----------------------------------------------------------------------- Summary of changes: WINGs/array.c | 12 ++-- WINGs/findfile.c | 128 ++++++++++++++++++--------- WINGs/proplist.c | 13 +++- WINGs/wbrowser.c | 11 +-- WINGs/wslider.c | 8 +- WINGs/wview.c | 6 ++ WPrefs.app/Appearance.c | 12 +++ WPrefs.app/KeyboardShortcuts.c | 2 +- WPrefs.app/po/de.po | 6 +- po/be.po | 4 +- po/bg.po | 4 +- po/bs.po | 4 +- po/ca.po | 4 +- po/cs.po | 4 +- po/da.po | 4 +- po/de.po | 4 +- po/es.po | 4 +- po/et.po | 4 +- po/fi.po | 4 +- po/fr.po | 20 +---- po/gl.po | 4 +- po/hr.po | 4 +- po/hu.po | 4 +- po/it.po | 5 +- po/ja.po | 4 +- po/ko.po | 4 +- po/ms.po | 4 +- po/nl.po | 4 +- po/no.po | 4 +- po/pl.po | 4 +- po/pt.po | 4 +- po/ru.po | 4 +- po/sk.po | 4 +- po/tr.po | 4 +- po/zh_CN.po | 4 +- po/zh_TW.po | 4 +- src/WindowMaker.h | 2 +- src/appicon.c | 2 +- src/balloon.c | 29 ++++--- src/client.c | 7 +- src/defaults.c | 82 ++++------------- src/dock.c | 15 ++-- src/dockedapp.c | 7 +- src/framewin.c | 8 +- src/icon.c | 4 +- src/icon.h | 3 +- src/main.c | 19 ++++- src/menu.c | 7 +- src/misc.c | 196 +++++++++++++++++++++++++++++----------- src/misc.h | 3 + src/moveres.c | 8 +- src/rootmenu.c | 61 +++++++++---- src/screen.c | 6 ++ src/texture.c | 2 - src/wdefaults.c | 37 ++++---- 55 files changed, 483 insertions(+), 338 deletions(-) repo.or.cz automatic notification. Contact project admin crma...@gmail.com if you want to unsubscribe, or site admin ad...@repo.or.cz if you receive no reply. -- wmaker-crm.git ("The Window Maker window manager") -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.