$NetBSD: patch-am,v 1.2 2025/10/20 18:32:10 vins Exp $ * Remove the default display :0 (solves CVE-2008-1142) * Replace deprecated XKeycodeToKeysym. --- src/init.c.orig 2002-12-04 05:21:39.000000000 +0000 +++ src/init.c @@ -33,6 +33,7 @@ #include "../config.h" /* NECESSARY */ #include "rxvt.h" /* NECESSARY */ +#include /* XKB */ #include "init.h" #include @@ -532,14 +533,13 @@ rxvt_init_resources(rxvt_t *r, int argc, /* * Open display, get options/resources and create the window */ - if ((rs[Rs_display_name] = getenv("DISPLAY")) == NULL) - rs[Rs_display_name] = ":0"; + rs[Rs_display_name] = getenv("DISPLAY"); rxvt_get_options(r, r_argc, r_argv); free(r_argv); #ifdef LOCAL_X_IS_UNIX - if (rs[Rs_display_name][0] == ':') { + if (rs[Rs_display_name] && rs[Rs_display_name][0] == ':') { val = rxvt_malloc(5 + STRLEN(rs[Rs_display_name])); STRCPY(val, "unix"); STRCAT(val, rs[Rs_display_name]); @@ -550,7 +550,9 @@ rxvt_init_resources(rxvt_t *r, int argc, if (r->Xdisplay == NULL && (r->Xdisplay = XOpenDisplay(rs[Rs_display_name])) == NULL) { - rxvt_print_error("can't open display %s", rs[Rs_display_name]); + rxvt_print_error("can't open display %s", rs[Rs_display_name] ? + rs[Rs_display_name] : getenv("DISPLAY")?getenv("DISPLAY") : + "as no -display given and DISPLAY not set"); exit(EXIT_FAILURE); } @@ -1016,7 +1018,7 @@ rxvt_get_ourmods(rxvt_t *r) for (j = map->max_keypermod; j--; k++) { if (kc[k] == 0) break; - switch (XKeycodeToKeysym(r->Xdisplay, kc[k], 0)) { + switch (XkbKeycodeToKeysym(r->Xdisplay, kc[k], 0, 0)) { case XK_Num_Lock: r->h->ModNumLockMask = modmasks[i - 1]; /* FALLTHROUGH */