diff --git a/xscreensaver-5.12-XLookupString-may-return-string.patch b/xscreensaver-5.12-XLookupString-may-return-string.patch deleted file mode 100644 index c172739..0000000 --- a/xscreensaver-5.12-XLookupString-may-return-string.patch +++ /dev/null @@ -1,127 +0,0 @@ ---- xscreensaver-5.12/driver/lock.c.debug 2010-09-15 17:43:26.000000000 +0900 -+++ xscreensaver-5.12/driver/lock.c 2011-03-08 02:28:39.000000000 +0900 -@@ -89,6 +89,9 @@ - int previous_mouse_x, previous_mouse_y; - - char typed_passwd [80]; -+ char keysym_buf_size [80]; /* note that each item stored in the array -+ keysym_buf_size should be 0 - 10 */ -+ - XtIntervalId timer; - int i_beam; - -@@ -1234,6 +1237,7 @@ - } - - memset (pw->typed_passwd, 0, sizeof(pw->typed_passwd)); -+ memset (pw->keysym_buf_size, 0, sizeof(pw->keysym_buf_size)); - memset (pw->passwd_string, 0, strlen(pw->passwd_string)); - - if (pw->timer) -@@ -1695,14 +1699,18 @@ - passwd_dialog_data *pw = si->pw_data; - int pw_size = sizeof (pw->typed_passwd) - 1; - char *typed_passwd = pw->typed_passwd; -- char s[2]; -+ char *keysym_buf_size = pw->keysym_buf_size; -+ char s[11]; - char *stars = 0; - int i; -- int size = XLookupString (event, s, 1, 0, compose_status); -+ /* So XLookupString may return string when the meaning of a KeySym -+ is rebinded by XRebindKeysym, for example. So let's try to read -+ not only 1 byte. */ -+ int size = XLookupString (event, s, 10, 0, compose_status); - -- if (size != 1) return; -+ if (size > 10) return; - -- s[1] = 0; -+ s[size] = 0; - - pw->passwd_changed_p = True; - -@@ -1716,37 +1724,58 @@ - if (!*typed_passwd) - XBell (si->dpy, 0); - else -- typed_passwd [strlen(typed_passwd)-1] = 0; -+ { -+ int keysym_buf_len = (int) strlen(keysym_buf_size); -+ int last_keysym_buf_size = keysym_buf_size[keysym_buf_len - 1]; -+ char *c; -+ int j; -+ -+ keysym_buf_size[keysym_buf_len - 1] = 0; -+ c = typed_passwd + (strlen(typed_passwd) - 1); -+ /* Delete the last characters of the length which -+ XLookupString returned and was preserved in -+ keysym_buf_size -+ */ -+ for ( j = 0; j < last_keysym_buf_size; j++ ) -+ *c-- = 0; -+ } - break; - - case '\025': case '\030': /* Erase line */ - memset (typed_passwd, 0, pw_size); -+ memset (keysym_buf_size, 0, pw_size); - break; - - case '\012': case '\015': /* Enter */ -+ memset (keysym_buf_size, 0, pw_size); - finished_typing_passwd(si, pw); - break; - - case '\033': /* Escape */ -+ memset (keysym_buf_size, 0, pw_size); - si->unlock_state = ul_cancel; - break; - - default: -- /* Though technically the only illegal characters in Unix passwords -- are LF and NUL, most GUI programs (e.g., GDM) use regular text-entry -- fields that only let you type printable characters. So, people -- who use funky characters in their passwords are already broken. -- We follow that precedent. -- */ -- if (isprint ((unsigned char) *s)) -+ /* As user may be using non-ascii character, let's allow -+ any character */ -+ if (1 || isprint ((unsigned char) *s)) - { - i = strlen (typed_passwd); -- if (i >= pw_size-1) -+ if (i >= pw_size - size) - XBell (si->dpy, 0); - else - { -- typed_passwd [i] = *s; -- typed_passwd [i+1] = 0; -+ char *c = keysym_buf_size; -+ int j; -+ int keysym_buf_len = strlen(keysym_buf_size); -+ -+ c+= keysym_buf_len; -+ *c++ = (char) size; /* save what size XLookupString returned, -+ should be 0 - 10 */ -+ *c = 0; -+ for (j = 0; j <= size; j++) -+ typed_passwd [i + j] = s[j]; - } - } - else -@@ -1911,6 +1940,13 @@ - - memcpy (pw->typed_passwd, si->unlock_typeahead, i); - pw->typed_passwd [i] = 0; -+ { -+ int j; -+ char *c = pw->keysym_buf_size; -+ for (j = 0; j < i; j++) -+ *c++ = 1; -+ *c = 0; -+ } - - memset (si->unlock_typeahead, '*', strlen(si->unlock_typeahead)); - si->unlock_typeahead[i] = 0; diff --git a/xscreensaver-5.12-test-passwd-segv-tty.patch b/xscreensaver-5.12-test-passwd-segv-tty.patch new file mode 100644 index 0000000..73ced5d --- /dev/null +++ b/xscreensaver-5.12-test-passwd-segv-tty.patch @@ -0,0 +1,11 @@ +--- xscreensaver-5.12/driver/passwd.c.debug2 2008-12-27 19:17:26.000000000 +0900 ++++ xscreensaver-5.12/driver/passwd.c 2011-04-03 21:55:26.000000000 +0900 +@@ -205,7 +205,7 @@ + { + # ifdef HAVE_SYSLOG + struct passwd *pw = getpwuid (getuid ()); +- char *d = DisplayString (si->dpy); ++ char *d = (si->dpy ? DisplayString (si->dpy) : 0); + char *u = (pw && pw->pw_name ? pw->pw_name : "???"); + int opt = 0; + int fac = 0; diff --git a/xscreensaver-5.12-tests-miscfix.patch b/xscreensaver-5.12-tests-miscfix.patch new file mode 100644 index 0000000..7ec1f48 --- /dev/null +++ b/xscreensaver-5.12-tests-miscfix.patch @@ -0,0 +1,21 @@ +--- xscreensaver-5.12/driver/test-xdpms.c.extra 2002-03-19 08:57:42.000000000 +0900 ++++ xscreensaver-5.12/driver/test-xdpms.c 2011-04-03 22:05:01.000000000 +0900 +@@ -29,7 +29,6 @@ + + #include + #include +-#include + + extern Bool DPMSQueryExtension (Display *dpy, int *event_ret, int *error_ret); + extern Bool DPMSCapable (Display *dpy); +--- xscreensaver-5.12/driver/Makefile.in 2011-04-03 22:49:32.000000000 +0900 ++++ xscreensaver-5.12/driver/Makefile.in.save 2011-04-03 22:49:32.000000000 +0900 +@@ -850,7 +850,7 @@ + test-mlstring: test-mlstring.o + $(CC) -DTEST $(LDFLAGS) -o $@ test-mlstring.o $(SAVER_LIBS) + +-TEST_FADE_OBJS = test-fade.o $(UTILS_SRC)/fade.o $(DEMO_UTIL_OBJS) ++TEST_FADE_OBJS = test-fade.o $(UTILS_BIN)/fade.o $(DEMO_UTIL_OBJS) + test-fade: test-fade.o $(UTILS_BIN)/fade.o + $(CC) $(LDFLAGS) -o $@ $(TEST_FADE_OBJS) $(SAVER_LIBS) + diff --git a/xscreensaver-5.12-upst-XLookupString-may-return-string.patch b/xscreensaver-5.12-upst-XLookupString-may-return-string.patch new file mode 100644 index 0000000..93f4508 --- /dev/null +++ b/xscreensaver-5.12-upst-XLookupString-may-return-string.patch @@ -0,0 +1,337 @@ +--- xscreensaver-5.12/driver/lock.c.debug 2010-09-15 17:43:26.000000000 +0900 ++++ xscreensaver-5.12/driver/lock.c 2011-04-03 17:51:36.000000000 +0900 +@@ -1,5 +1,5 @@ + /* lock.c --- handling the password dialog for locking-mode. +- * xscreensaver, Copyright (c) 1993-2008 Jamie Zawinski ++ * xscreensaver, Copyright (c) 1993-2011 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that +@@ -83,12 +83,23 @@ + + typedef struct info_dialog_data info_dialog_data; + ++ ++#define MAX_BYTES_PER_CHAR 8 /* UTF-8 uses no more than 3, I think */ ++#define MAX_PASSWD_CHARS 128 /* Longest possible passphrase */ ++ + struct passwd_dialog_data { + + saver_screen_info *prompt_screen; + int previous_mouse_x, previous_mouse_y; + +- char typed_passwd [80]; ++ /* "Characters" in the password may be a variable number of bytes long. ++ typed_passwd contains the raw bytes. ++ typed_passwd_char_size indicates the size in bytes of each character, ++ so that we can make backspace work. ++ */ ++ char typed_passwd [MAX_PASSWD_CHARS * MAX_BYTES_PER_CHAR]; ++ char typed_passwd_char_size [MAX_PASSWD_CHARS]; ++ + XtIntervalId timer; + int i_beam; + +@@ -128,6 +139,7 @@ + + Pixel foreground; + Pixel background; ++ Pixel border; + Pixel passwd_foreground; + Pixel passwd_background; + Pixel thermo_foreground; +@@ -308,6 +320,9 @@ + pw->background = get_pixel_resource (si->dpy, cmap, + "passwd.background", + "Dialog.Background" ); ++ pw->border = get_pixel_resource (si->dpy, cmap, ++ "passwd.borderColor", ++ "Dialog.borderColor"); + + if (pw->foreground == pw->background) + { +@@ -413,6 +428,9 @@ + } + + ++Bool debug_passwd_window_p = False; /* used only by test-passwd.c ? */ ++ ++ + /** + * info_msg and prompt may be NULL. + */ +@@ -614,6 +632,9 @@ + + attrmask |= CWOverrideRedirect; attrs.override_redirect = True; + ++ if (debug_passwd_window_p) ++ attrs.override_redirect = False; /* kludge for test-passwd.c */ ++ + attrmask |= CWEventMask; + attrs.event_mask = (ExposureMask | KeyPressMask | + ButtonPressMask | ButtonReleaseMask); +@@ -648,6 +669,7 @@ + DefaultVisualOfScreen(screen), + attrmask, &attrs); + XSetWindowBackground (si->dpy, si->passwd_dialog, pw->background); ++ XSetWindowBorder (si->dpy, si->passwd_dialog, pw->border); + + /* We use the default visual, not ssi->visual, so that the logo pixmap's + visual matches that of the si->passwd_dialog window. */ +@@ -1234,6 +1256,7 @@ + } + + memset (pw->typed_passwd, 0, sizeof(pw->typed_passwd)); ++ memset (pw->typed_passwd_char_size, 0, sizeof(pw->typed_passwd_char_size)); + memset (pw->passwd_string, 0, strlen(pw->passwd_string)); + + if (pw->timer) +@@ -1693,85 +1716,126 @@ + handle_passwd_key (saver_info *si, XKeyEvent *event) + { + passwd_dialog_data *pw = si->pw_data; +- int pw_size = sizeof (pw->typed_passwd) - 1; +- char *typed_passwd = pw->typed_passwd; +- char s[2]; +- char *stars = 0; +- int i; +- int size = XLookupString (event, s, 1, 0, compose_status); ++ unsigned char decoded [MAX_BYTES_PER_CHAR * 10]; /* leave some slack */ ++ KeySym keysym = 0; + +- if (size != 1) return; ++ /* XLookupString may return more than one character via XRebindKeysym; ++ and on some systems it returns multi-byte UTF-8 characters (contrary ++ to its documentation, which says it returns only Latin1.) ++ */ ++ int decoded_size = XLookupString (event, (char *)decoded, sizeof(decoded), ++ &keysym, compose_status); + +- s[1] = 0; ++#if 0 ++ { ++ const char *ks = XKeysymToString (keysym); ++ int i; ++ fprintf(stderr, "## %-12s\t=> %d\t", (ks ? ks : "(null)"), decoded_size); ++ for (i = 0; i < decoded_size; i++) ++ fprintf(stderr, "%c", decoded[i]); ++ fprintf(stderr, "\t"); ++ for (i = 0; i < decoded_size; i++) ++ fprintf(stderr, "\\%03o", ((unsigned char *)decoded)[i]); ++ fprintf(stderr, "\n"); ++ } ++#endif + ++ if (decoded_size > MAX_BYTES_PER_CHAR) ++ { ++ /* The multi-byte character returned is too large. */ ++ XBell (si->dpy, 0); ++ return; ++ } ++ ++ decoded[decoded_size] = 0; + pw->passwd_changed_p = True; + + /* Add 10% to the time remaining every time a key is pressed. */ + pw->ratio += 0.1; + if (pw->ratio > 1) pw->ratio = 1; + +- switch (*s) ++ if (decoded_size == 1) /* Handle single-char commands */ + { +- case '\010': case '\177': /* Backspace */ +- if (!*typed_passwd) +- XBell (si->dpy, 0); +- else +- typed_passwd [strlen(typed_passwd)-1] = 0; +- break; +- +- case '\025': case '\030': /* Erase line */ +- memset (typed_passwd, 0, pw_size); +- break; +- +- case '\012': case '\015': /* Enter */ +- finished_typing_passwd(si, pw); +- break; +- +- case '\033': /* Escape */ +- si->unlock_state = ul_cancel; +- break; +- +- default: +- /* Though technically the only illegal characters in Unix passwords +- are LF and NUL, most GUI programs (e.g., GDM) use regular text-entry +- fields that only let you type printable characters. So, people +- who use funky characters in their passwords are already broken. +- We follow that precedent. +- */ +- if (isprint ((unsigned char) *s)) ++ switch (*decoded) + { +- i = strlen (typed_passwd); +- if (i >= pw_size-1) ++ case '\010': case '\177': /* Backspace */ ++ { ++ /* kludgey way to get the number of "logical" characters. */ ++ int nchars = strlen (pw->typed_passwd_char_size); ++ int nbytes = strlen (pw->typed_passwd); ++ if (nbytes <= 0) ++ XBell (si->dpy, 0); ++ else ++ { ++ int i; ++ for (i = pw->typed_passwd_char_size[nchars-1]; i >= 0; i--) ++ { ++ if (nbytes < 0) abort(); ++ pw->typed_passwd[nbytes--] = 0; ++ } ++ pw->typed_passwd_char_size[nchars-1] = 0; ++ } ++ } ++ break; ++ ++ case '\012': case '\015': /* Enter */ ++ finished_typing_passwd (si, pw); ++ break; ++ ++ case '\033': /* Escape */ ++ si->unlock_state = ul_cancel; ++ break; ++ ++ case '\025': case '\030': /* Erase line */ ++ memset (pw->typed_passwd, 0, sizeof (pw->typed_passwd)); ++ memset (pw->typed_passwd_char_size, 0, ++ sizeof (pw->typed_passwd_char_size)); ++ break; ++ ++ default: ++ if (*decoded < ' ' && *decoded != '\t') /* Other ctrl char */ + XBell (si->dpy, 0); + else +- { +- typed_passwd [i] = *s; +- typed_passwd [i+1] = 0; +- } ++ goto SELF_INSERT; ++ break; + } +- else ++ } ++ else ++ { ++ int nbytes, nchars; ++ SELF_INSERT: ++ nbytes = strlen (pw->typed_passwd); ++ nchars = strlen (pw->typed_passwd_char_size); ++ if (nchars + 1 >= sizeof (pw->typed_passwd_char_size)-1 || ++ nbytes + decoded_size >= sizeof (pw->typed_passwd)-1) /* overflow */ + XBell (si->dpy, 0); +- break; ++ else ++ { ++ pw->typed_passwd_char_size[nchars] = decoded_size; ++ pw->typed_passwd_char_size[nchars+1] = 0; ++ memcpy (pw->typed_passwd + nbytes, decoded, decoded_size); ++ pw->typed_passwd[nbytes + decoded_size] = 0; ++ } + } + + if (pw->echo_input) + { +- /* If the input is wider than the text box, only show the last portion. +- * This simulates a horizontally scrolling text field. */ ++ /* If the input is wider than the text box, only show the last portion, ++ to simulate a horizontally-scrolling text field. */ + int chars_in_pwfield = (pw->passwd_field_width / + pw->passwd_font->max_bounds.width); +- +- if (strlen(typed_passwd) > chars_in_pwfield) +- typed_passwd += (strlen(typed_passwd) - chars_in_pwfield); +- +- update_passwd_window(si, typed_passwd, pw->ratio); ++ const char *output = pw->typed_passwd; ++ if (strlen(output) > chars_in_pwfield) ++ output += (strlen(output) - chars_in_pwfield); ++ update_passwd_window (si, output, pw->ratio); + } + else if (pw->show_stars_p) + { +- i = strlen(typed_passwd); +- stars = (char *) malloc(i+1); +- memset (stars, '*', i); +- stars[i] = 0; ++ int nchars = strlen (pw->typed_passwd_char_size); ++ char *stars = 0; ++ stars = (char *) malloc(nchars + 1); ++ memset (stars, '*', nchars); ++ stars[nchars] = 0; + update_passwd_window (si, stars, pw->ratio); + free (stars); + } +@@ -1911,6 +1975,13 @@ + + memcpy (pw->typed_passwd, si->unlock_typeahead, i); + pw->typed_passwd [i] = 0; ++ { ++ int j; ++ char *c = pw->typed_passwd_char_size; ++ for (j = 0; j < i; j++) ++ *c++ = 1; ++ *c = 0; ++ } + + memset (si->unlock_typeahead, '*', strlen(si->unlock_typeahead)); + si->unlock_typeahead[i] = 0; +@@ -2054,6 +2125,7 @@ + fail: + if (compose_status) + free (compose_status); ++ compose_status = 0; + + if (responses) + { +--- xscreensaver-5.12/driver/test-passwd.c.debug 2010-08-24 05:22:23.000000000 +0900 ++++ xscreensaver-5.12/driver/test-passwd.c 2011-04-03 21:27:46.000000000 +0900 +@@ -1,4 +1,4 @@ +-/* xscreensaver, Copyright (c) 1998-2008 Jamie Zawinski ++/* xscreensaver, Copyright (c) 1998-2011 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + + #include "xscreensaver.h" + #include "resources.h" +@@ -135,6 +136,8 @@ + 0 + }; + ++extern Bool debug_passwd_window_p; /* lock.c kludge */ ++ + int + main (int argc, char **argv) + { +@@ -199,6 +202,11 @@ + + progclass = "XScreenSaver"; + ++ if (!setlocale(LC_ALL,"")) ++ fprintf (stderr, "%s: warning: could not set default locale\n", ++ progname); ++ ++ + if (which != TTY) + { + toplevel_shell = XtAppInitialize (&si->app, progclass, 0, 0, +@@ -243,6 +251,7 @@ + si->unlock_cb = gui_auth_conv; + si->auth_finished_cb = auth_finished_cb; + ++ debug_passwd_window_p = True; + xss_authenticate(si, True); + + if (si->unlock_state == ul_success) diff --git a/xscreensaver.spec b/xscreensaver.spec index c13521b..62a2217 100644 --- a/xscreensaver.spec +++ b/xscreensaver.spec @@ -10,7 +10,7 @@ %define split_getimage 1 %endif -%define fedora_rel 13 +%define fedora_rel 14 %undefine extrarel @@ -62,6 +62,7 @@ Patch30: xscreensaver-5.11-conf264.patch ## Patches which must be discussed with upstream # ## Patch31, 32, 33, 34, 35, 36, 37, 38, 39: already sent to the upstream +## Patch40: from the upstream # # For now set LANG to C for daemon because some garbage character appears # on passwd prompt @@ -92,8 +93,13 @@ Patch38: xscreensaver-5.12-apple2-1byte-ahead.patch Patch39: xscreensaver-5.12-webcollage-ppm-gnome569671.patch # Cannot type non-ascii character on password window # https://bugs.launchpad.net/ubuntu/+source/xscreensaver/+bug/671923 -# The following patch is still under discussion with jwz -Patch40: xscreensaver-5.12-XLookupString-may-return-string.patch +# Patch sent from the upstream, a bit modified +Patch40: xscreensaver-5.12-upst-XLookupString-may-return-string.patch +# driver/test-passwd tty segfaults +Patch41: xscreensaver-5.12-test-passwd-segv-tty.patch +# patch to compile driver/test-xdpms +Patch42: xscreensaver-5.12-tests-miscfix.patch +# # Patches end Requires: xscreensaver-base = %{epoch}:%{version}-%{release} Requires: xscreensaver-extras = %{epoch}:%{version}-%{release} @@ -292,6 +298,8 @@ This package contains some test programs to debug XScreenSaver. %patch38 -p1 -b .apple2_byte %patch39 -p1 -b .webc.ppm %patch40 -p1 -b .non_ascii +%patch41 -p1 -b .test_passwd +%patch42 -p1 -b .test_misc change_option(){ set +x @@ -409,10 +417,11 @@ sed -i.icon -e 's|xscreensaver\.xpm|xscreensaver|' \ # mlstring: causes OOM sed -i.test \ -e 's|test-apm[ \t][ \t]*t|t|' \ +%if 0 -e 's|test-passwd[ \t][ \t]*t|t|' \ +%endif -e 's|test-mlstring[ \t][ \t]*t|t|' \ driver/Makefile.in -sed -i.dir -e '/TEST_FADE_OBJS =/s|UTILS_SRC|UTILS_BIN|' driver/Makefile.in # test-fade: give more time between fading sed -i.delay -e 's| delay = 1| delay = 3|' driver/test-fade.c @@ -500,7 +509,9 @@ cd .. %endif # test -%if %{build_tests} +# for now, build tests anyway (even if they are not to be installed) +#%if %{build_tests} +%if 1 make tests -C driver %endif @@ -815,6 +826,11 @@ exit 0 %defattr(-,root,root,-) %changelog +* Sun Apr 3 2011 Mamoru Tasaka - 1:5.12-14 +- Patch40 revised by jwz +- Fix segv on test-passwd +- Fix compilation error on test-xdpms + * Sun Mar 20 2011 Mamoru Tasaka - 1:5.12-13 - Trial patch to allow non-ascii characters on passwd window (Ubuntu bug 671923)