Fix a crash if -D' is used without -t title'

dialog(3)'s dlg_reallocate_gauge(), used both by dialog(3)'s dialog_gauge()
and dialog(1)'s `--gauge', will segmentation fault in strlen(3) if no title
is set for the widget. Reproducible with `dialog --gauge hi 6 20' (adding
`--title ""' is enough to prevent segmentation fault).

MFC after:	3 days
X-MFC-to:	stable/10
This commit is contained in:
Devin Teske 2016-01-27 06:21:35 +00:00
parent 138b115fcb
commit b888adc784
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=294893

View file

@ -261,6 +261,13 @@ dialog_spawn_gauge(char *init_prompt, pid_t *pid)
errx(EXIT_FAILURE, "Out of memory?!");
sprintf(dargv[n++], "--title");
dargv[n++] = title;
} else {
if ((dargv[n] = malloc(8)) == NULL)
errx(EXIT_FAILURE, "Out of memory?!");
sprintf(dargv[n++], "--title");
if ((dargv[n] = malloc(8)) == NULL)
errx(EXIT_FAILURE, "Out of memory?!");
sprintf(dargv[n++], "");
}
if (backtitle != NULL) {
if ((dargv[n] = malloc(12)) == NULL)