From: Benjamin Kaduk Date: Sat, 2 Feb 2019 23:02:08 +0000 (-0600) Subject: scout: band-aid -Wformat-truncation X-Git-Tag: upstream/1.8.6_pre1^2~65 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=b86c1f142add117065399186292655873bc7fdc0;p=packages%2Fo%2Fopenafs.git scout: band-aid -Wformat-truncation gcc8 gets pretty confused about the bounds on these things (presumably due to our alignment options) and thinks this could potentially be a huge string. Check for truncation to appease the compiler, instead of trying to ensure that the buffer is big enough. Reviewed-on: https://gerrit.openafs.org/13470 Tested-by: BuildBot Reviewed-by: Cheyenne Wills Reviewed-by: Michael Meffie Tested-by: Michael Meffie Reviewed-by: Benjamin Kaduk (cherry picked from commit df8534909fdc1fa8417aa788c0fa71c5dbe7eb30) Change-Id: Idf3a2f32ba4630a7d11b2c0664c6dd9b694eb7db Reviewed-on: https://gerrit.openafs.org/13739 Reviewed-by: Andrew Deason Reviewed-by: Marcio Brito Barbosa Reviewed-by: Michael Meffie Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- diff --git a/src/scout/scout.c b/src/scout/scout.c index 9396c50b7..3770e0db2 100644 --- a/src/scout/scout.c +++ b/src/scout/scout.c @@ -1801,14 +1801,18 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg) snprintf(attn_label, sizeof(attn_label), "%s: < %d blocks free", scout_label[5], scout_attn_disk_minfree); } - snprintf(scout_Banner, sizeof(scout_Banner), - "%*s %*s %*s %*s %*s %s", - scout_col_width[0], scout_label[0], - scout_col_width[1], scout_label[1], - scout_col_width[2], scout_label[2], - scout_col_width[3], scout_label[3], - scout_col_width[4], scout_label[4], - attn_label); + code = snprintf(scout_Banner, sizeof(scout_Banner), + "%*s %*s %*s %*s %*s %s", + scout_col_width[0], scout_label[0], + scout_col_width[1], scout_label[1], + scout_col_width[2], scout_label[2], + scout_col_width[3], scout_label[3], + scout_col_width[4], scout_label[4], + attn_label); + if (code < 0 || code >= sizeof(scout_Banner)) { + fprintf(stderr, "[%s] Truncation while generating banner\n", rn); + return -1; + } lightdata = (struct gator_lightobj *)(scout_banner1_lp->o_data); mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx,