#ifdef WIZARD
E void NDECL(sanity_check);
#endif
+E char FDECL(yn_function, (const char *, const char *, CHAR_P));
/* ### dbridge.c ### */
#define nh_poskey (*windowprocs.win_nh_poskey)
#define nhbell (*windowprocs.win_nhbell)
#define nh_doprev_message (*windowprocs.win_doprev_message)
-#define yn_function (*windowprocs.win_yn_function)
#define getlin (*windowprocs.win_getlin)
#define get_ext_cmd (*windowprocs.win_get_ext_cmd)
#define number_pad (*windowprocs.win_number_pad)
#define get_color_string (*windowprocs.win_get_color_string)
#endif
+/* 3.4.2: There is a real yn_function() in the core now, which does
+ * some buffer length validation on the parameters prior to
+ * invoking the window port routine. yn_function() is in cmd.c
+ */
+/* #define yn_function (*windowprocs.win_yn_function) */
+
/* other defs that really should go away (they're tty specific) */
#define start_screen (*windowprocs.win_start_screen)
#define end_screen (*windowprocs.win_end_screen)
# endif /*PORT_DEBUG*/
#endif /* OVL0 */
+#ifdef OVLB
+/*
+ * Parameter validator for generic yes/no function to prevent
+ * the core from sending too long a prompt string to the
+ * window port causing a buffer overflow there.
+ */
+char
+yn_function(query,resp, def)
+const char *query,*resp;
+char def;
+{
+ char qbuf[QBUFSZ];
+ unsigned truncspot, reduction = sizeof(" [N] ?") + 1;
+
+ if (resp) reduction += strlen(resp) + sizeof(" () ");
+ if (strlen(query) < (QBUFSZ - reduction))
+ return (*windowprocs.win_yn_function)(query, resp, def);
+ paniclog("Query truncated: ", query);
+ reduction += sizeof("...");
+ truncspot = QBUFSZ - reduction;
+ (void) strncpy(qbuf, query, truncspot);
+ qbuf[truncspot] = '\0';
+ Strcat(qbuf,"...");
+ return (*windowprocs.win_yn_function)(qbuf, resp, def);
+}
+#endif
/*cmd.c*/