From af70c2e8f06cff32f00932f06593174196ca4678 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 21 Jul 2018 20:24:03 +0200 Subject: [PATCH] cp_getvar with CP_STRING: add size of string to function parameters --- src/frontend/aspice.c | 8 ++++---- src/frontend/com_ghelp.c | 22 +++++++++++----------- src/frontend/display.c | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/frontend/aspice.c b/src/frontend/aspice.c index d5828d620..e08d0fcad 100644 --- a/src/frontend/aspice.c +++ b/src/frontend/aspice.c @@ -79,7 +79,7 @@ com_aspice(wordlist *wl) bool saveout = FALSE; deck = wl->wl_word; - if (!cp_getvar("spicepath", CP_STRING, spicepath)) { + if (!cp_getvar("spicepath", CP_STRING, spicepath, size_of(spicepath))) { if (!Spice_Path || !*Spice_Path) { fprintf(cp_err, "No spice-3 binary is available for the aspice command.\n"); @@ -282,11 +282,11 @@ com_rspice(wordlist *wl) char *p; /* Figure out where the spicedaemon is and connect to it. */ - if (!cp_getvar("rhost", CP_STRING, rhost)) + if (!cp_getvar("rhost", CP_STRING, rhost, size_of(rhost))) (void) strcpy(rhost, Spice_Host); - if (!cp_getvar("rprogram", CP_STRING, program)) + if (!cp_getvar("rprogram", CP_STRING, program, size_of(program))) *program = '\0'; - if (!cp_getvar("remote_shell", CP_STRING, remote_shell)) + if (!cp_getvar("remote_shell", CP_STRING, remote_shell, size_of(remote_shell))) strcpy(remote_shell, "rsh"); if (*rhost == '\0') { diff --git a/src/frontend/com_ghelp.c b/src/frontend/com_ghelp.c index 2eef8f4bc..5d9afa089 100644 --- a/src/frontend/com_ghelp.c +++ b/src/frontend/com_ghelp.c @@ -34,7 +34,7 @@ com_ghelp(wordlist *wl) int i; #endif /* X_DISPLAY_MISSING 1 */ - if (cp_getvar("helppath", CP_STRING, buf)) + if (cp_getvar("helppath", CP_STRING, , size_of(buf))) path = copy(buf); if (!path) { fprintf(cp_err, "Note: defaulting to old help.\n\n"); @@ -50,21 +50,21 @@ com_ghelp(wordlist *wl) #ifndef X_DISPLAY_MISSING /* 1 */ path = npath; - if (cp_getvar("helpregfont", CP_STRING, buf)) + if (cp_getvar("helpregfont", CP_STRING, buf, size_of(buf))) hlp_regfontname = copy(buf); - if (cp_getvar("helpboldfont", CP_STRING, buf)) + if (cp_getvar("helpboldfont", CP_STRING, buf, size_of(buf))) hlp_boldfontname = copy(buf); - if (cp_getvar("helpitalicfont", CP_STRING, buf)) + if (cp_getvar("helpitalicfont", CP_STRING, buf, size_of(buf))) hlp_italicfontname = copy(buf); - if (cp_getvar("helptitlefont", CP_STRING, buf)) + if (cp_getvar("helptitlefont", CP_STRING, buf, size_of(buf))) hlp_titlefontname = copy(buf); - if (cp_getvar("helpbuttonfont", CP_STRING, buf)) + if (cp_getvar("helpbuttonfont", CP_STRING, buf, size_of(buf))) hlp_buttonfontname = copy(buf); - if (cp_getvar("helpinitxpos", CP_NUM, &i)) + if (cp_getvar("helpinitxpos", CP_NUM, &i, 0)) hlp_initxpos = i; - if (cp_getvar("helpinitypos", CP_NUM, &i)) + if (cp_getvar("helpinitypos", CP_NUM, &i, 0)) hlp_initypos = i; - if (cp_getvar("helpbuttonstyle", CP_STRING, buf)) { + if (cp_getvar("helpbuttonstyle", CP_STRING, buf, size_of(buf))) { if (cieq(buf, "left")) hlp_buttonstyle = BS_LEFT; else if (cieq(buf, "center")) @@ -77,9 +77,9 @@ com_ghelp(wordlist *wl) } if (cp_getvar("width", CP_NUM, &i)) hlp_width = i; - if (cp_getvar("display", CP_STRING, buf)) + if (cp_getvar("display", CP_STRING, buf, size_of(buf))) hlp_displayname = copy(buf); - else if (cp_getvar("device", CP_STRING, buf)) + else if (cp_getvar("device", CP_STRING, buf, size_of(buf))) hlp_displayname = copy(buf); else hlp_displayname = NULL; diff --git a/src/frontend/display.c b/src/frontend/display.c index 7db765f4d..31779d3b8 100644 --- a/src/frontend/display.c +++ b/src/frontend/display.c @@ -169,7 +169,7 @@ DevInit(void) #ifndef X_DISPLAY_MISSING /* determine display type */ - if (getenv("DISPLAY") || cp_getvar("display", CP_STRING, buf)) + if (getenv("DISPLAY") || cp_getvar("display", CP_STRING, buf, size_of(buf))) dispdev = FindDev("X11"); #endif