summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/Makefile.in2
-rw-r--r--utils/colors.c15
-rw-r--r--utils/erase.c2
-rw-r--r--utils/font-retry.c43
-rw-r--r--utils/textclient-mobile.c14
-rw-r--r--utils/version.h2
-rw-r--r--utils/yarandom.h34
7 files changed, 89 insertions, 23 deletions
diff --git a/utils/Makefile.in b/utils/Makefile.in
index 56fc602..dbb593b 100644
--- a/utils/Makefile.in
+++ b/utils/Makefile.in
@@ -195,7 +195,7 @@ CCUTILS = $(INCLUDES) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(X_CFLAGS)
$(CC) -c $(CCUTILS) $<
# Two versions of this: driver/ does not link with Xft, but hacks/ does.
-font-retry-xft.o: font-retry.c
+font-retry-xft.o: $(srcdir)/font-retry.c
$(CC) -c $(CCUTILS) -DUSE_XFT $< -o $@
diff --git a/utils/colors.c b/utils/colors.c
index e6abd48..5445cd6 100644
--- a/utils/colors.c
+++ b/utils/colors.c
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1997-2013 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1997-2018 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -383,9 +383,22 @@ make_color_path (Screen *screen, Visual *visual, Colormap cmap,
/* Floating-point round-off can make us decide to use fewer colors. */
if (k < *ncolorsP)
{
+ /* We used to just return the smaller set of colors, but that meant
+ that after re-generating the color map repeatedly, the number of
+ colors in use would tend toward 0, which not only looked bad but
+ also often caused crashes. So instead, just duplicate the last
+ color to pad things out. */
+# if 0
*ncolorsP = k;
if (k <= 0)
return;
+# else
+ for (i = k+1; i < *ncolorsP; i++)
+ /* #### Should duplicate the allocation of the color cell here
+ to avoid a double-color-free on PseudoColor, but it's 2018
+ and I don't care, */
+ colors[i] = colors[k];
+# endif
}
if (!allocate_p)
diff --git a/utils/erase.c b/utils/erase.c
index ae15ac8..fdf7496 100644
--- a/utils/erase.c
+++ b/utils/erase.c
@@ -750,7 +750,7 @@ eraser_init (Display *dpy, Window window)
which = -1;
else
which = get_integer_resource(dpy, "eraseMode", "Integer");
- free (s);
+ if (s) free (s);
if (which < 0 || which >= countof(erasers))
which = random() % countof(erasers);
diff --git a/utils/font-retry.c b/utils/font-retry.c
index c3e91a0..ab999e2 100644
--- a/utils/font-retry.c
+++ b/utils/font-retry.c
@@ -25,19 +25,21 @@ extern const char *progname;
#undef countof
#define countof(x) (sizeof((x))/sizeof((*x)))
+#undef DEBUG
+
static void *
load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
{
# ifdef USE_XFT
-# define LOADFONT() (xft_p \
- ? (void *) XftFontOpenXlfd (dpy, screen, xlfd) \
- : (void *) XLoadQueryFont (dpy, xlfd))
+# define LOADFONT(F) (xft_p \
+ ? (void *) XftFontOpenXlfd (dpy, screen, (F)) \
+ : (void *) XLoadQueryFont (dpy, (F)))
# else
-# define LOADFONT() ((void *) XLoadQueryFont (dpy, xlfd))
+# define LOADFONT(F) ((void *) XLoadQueryFont (dpy, (F)))
# endif
- void *f = LOADFONT();
+ void *f = xlfd ? LOADFONT(xlfd) : 0;
# ifndef USE_XFT
if (xft_p) abort();
@@ -46,11 +48,18 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
# ifdef HAVE_JWXYZ
return f;
# else /* !HAVE_JWXYZ */
+ if (! xlfd) xlfd = "<null>";
if (f)
- return f;
+ {
+# ifdef DEBUG
+ fprintf (stderr, "%s: loaded %s\n", progname, xlfd);
+# endif
+ return f;
+ }
else
{
- Bool bold_p = (!!strcasestr (xlfd, "-bold-"));
+ Bool bold_p = (!!strcasestr (xlfd, "-bold-") ||
+ !!strcasestr (xlfd, "-ocr"));
Bool italic_p = (!!strcasestr (xlfd, "-i-") ||
!!strcasestr (xlfd, "-o-"));
Bool fixed_p = (!!strcasestr (xlfd, "courier") ||
@@ -59,6 +68,10 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
!!strcasestr (xlfd, "-c-"));
int size = 0;
+# ifdef DEBUG
+ fprintf (stderr, "%s: failed %s\n", progname, xlfd);
+# endif
+
if (!strcmp (xlfd, "vga")) /* BSOD uses this: it has no XLFD name. */
fixed_p = True, size = 120;
@@ -90,7 +103,7 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
fprintf (stderr, "%s: unloadable, unparsable font: \"%s\"\n",
progname, xlfd);
xlfd = "fixed";
- return LOADFONT();
+ return LOADFONT(xlfd);
}
else
{
@@ -145,13 +158,17 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
spacings[e],
"*", /* average width */
charsets[a]);
- /* fprintf(stderr, "%s: trying %s\n", progname, buf);*/
- f = LOADFONT();
+# ifdef DEBUG
+ fprintf(stderr, "%s: trying %s\n", progname, buf);
+# endif
+ f = LOADFONT(buf);
if (f)
{
- /* fprintf (stderr,
+# ifdef DEBUG
+ fprintf (stderr,
"%s: substituted \"%s\" for \"%s\"\n",
- progname, buf, xlfd); */
+ progname, buf, xlfd);
+# endif
return f;
}
}
@@ -159,7 +176,7 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
fprintf (stderr, "%s: unable to find any alternatives to \"%s\"\n",
progname, xlfd);
xlfd = "fixed";
- return LOADFONT();
+ return LOADFONT(xlfd);
}
}
# endif /* !HAVE_JWXYZ */
diff --git a/utils/textclient-mobile.c b/utils/textclient-mobile.c
index c321487..4d0d891 100644
--- a/utils/textclient-mobile.c
+++ b/utils/textclient-mobile.c
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 2012-2016 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 2012-2018 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -311,11 +311,13 @@ textclient_strip_html (const char *html)
int comment = 0;
int white = 0;
int nl = 0;
- char *ret = (char *) malloc ((strlen(html) * 4) + 1); // room for UTF8
+ int L = strlen(html);
+ char *ret = (char *) malloc ((L * 4) + 1); // room for UTF8
char *out = ret;
*out = 0;
for (const char *in = html; *in; in++) {
+ if (in >= html + L) abort();
if (comment) {
if (!strncmp (in, "-->", 3)) {
comment = 0;
@@ -339,7 +341,7 @@ textclient_strip_html (const char *html)
white = 1;
}
} else if (*in == ' ' || *in == '\t' || *in == '\r' || *in == '\n') {
- if (!white && out != html)
+ if (!white && out != ret)
*out++ = ' ';
white = 1;
} else {
@@ -552,7 +554,8 @@ strip_wiki (char *text)
static char *
textclient_strip_rss (const char *rss)
{
- char *ret = malloc (strlen(rss) * 4 + 1); // room for UTF8
+ int L = strlen(rss);
+ char *ret = malloc (L * 4 + 1); // room for UTF8
char *out = ret;
const char *a = 0, *b = 0, *c = 0, *d = 0, *t = 0;
int head = 1;
@@ -561,6 +564,7 @@ textclient_strip_rss (const char *rss)
*out = 0;
for (const char *in = rss; *in; in++) {
+ if (in >= rss + L) abort();
if (*in == '<') {
if (!strncasecmp (in, "<item", 5) || // New item, dump.
!strncasecmp (in, "<entry", 6)) {
@@ -592,6 +596,8 @@ textclient_strip_rss (const char *rss)
out += strlen (out);
}
+ if (done) break;
+
} else if (head) { // still before first <item>
;
} else if (!strncasecmp (in, "<title", 6)) {
diff --git a/utils/version.h b/utils/version.h
index 5ad7580..7bdae95 100644
--- a/utils/version.h
+++ b/utils/version.h
@@ -1,2 +1,2 @@
static const char screensaver_id[] =
- "@(#)xscreensaver 5.40 (12-Aug-2018), by Jamie Zawinski (jwz@jwz.org)";
+ "@(#)xscreensaver 5.42 (28-Dec-2018), by Jamie Zawinski (jwz@jwz.org)";
diff --git a/utils/yarandom.h b/utils/yarandom.h
index 711aadd..9a75cdf 100644
--- a/utils/yarandom.h
+++ b/utils/yarandom.h
@@ -25,8 +25,23 @@
#undef drand48
#undef srandom
#undef srand
-#undef srand48
#undef frand
+#undef sranddev
+#undef srandomdev
+#undef arc4random
+#undef arc4random_addrandom
+#undef arc4random_buf
+#undef arc4random_stir
+#undef arc4random_uniform
+#undef erand48
+#undef jrand48
+#undef lcong48
+#undef lrand48
+#undef mrand48
+#undef nrand48
+#undef seed48
+#undef srand48
+#undef rand_r
#undef RAND_MAX
#ifdef VMS
@@ -47,8 +62,23 @@ extern void ya_rand_init (unsigned int);
#define drand48 __ERROR_use_frand_not_drand48_in_xscreensaver__
#define srandom __ERROR_do_not_call_srandom_in_xscreensaver__
#define srand __ERROR_do_not_call_srand_in_xscreensaver__
-#define srand48 __ERROR_do_not_call_srand48_in_xscreensaver__
+#define sranddev __ERROR_do_not_call_sranddev_in_xscreensaver__
#define ya_rand_init __ERROR_do_not_call_ya_rand_init_in_xscreensaver__
+#define srandomdev __ERROR_do_not_call_srandomdev_in_xscreensaver__
+#define arc4random __ERROR_do_not_call_arc4random_in_xscreensaver__
+#define arc4random_addrandom __ERROR_do_not_call_arc4random_in_xscreensaver__
+#define arc4random_buf __ERROR_do_not_call_arc4random_in_xscreensaver__
+#define arc4random_stir __ERROR_do_not_call_arc4random_in_xscreensaver__
+#define arc4random_uniform __ERROR_do_not_call_arc4random_in_xscreensaver__
+#define erand48 __ERROR_do_not_call_erand48_in_xscreensaver__
+#define jrand48 __ERROR_do_not_call_jrand48_in_xscreensaver__
+#define lcong48 __ERROR_do_not_call_lcong48_in_xscreensaver__
+#define lrand48 __ERROR_do_not_call_lrand48_in_xscreensaver__
+#define mrand48 __ERROR_do_not_call_mrand48_in_xscreensaver__
+#define nrand48 __ERROR_do_not_call_nrand48_in_xscreensaver__
+#define seed48 __ERROR_do_not_call_seed48_in_xscreensaver__
+#define srand48 __ERROR_do_not_call_srand48_in_xscreensaver__
+#define rand_r __ERROR_do_not_call_rand_r_in_xscreensaver__
#if defined (__GNUC__) && (__GNUC__ >= 2)