Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 May 2016 05:45:52 +0000 (UTC)
From:      Don Lewis <truckman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r300473 - stable/10/usr.bin/ncal
Message-ID:  <201605230545.u4N5jqLc094915@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: truckman
Date: Mon May 23 05:45:52 2016
New Revision: 300473
URL: https://svnweb.freebsd.org/changeset/base/300473

Log:
  MFC r300005
  
  swprintf() and apparently wcsftime() want the their output buffer size
  specified in terms of the the number of wide characters and not
  sizeof(buffer).
  
  Reported by:	Coverity
  CID:		1007605, 1007606

Modified:
  stable/10/usr.bin/ncal/ncal.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/ncal/ncal.c
==============================================================================
--- stable/10/usr.bin/ncal/ncal.c	Mon May 23 05:43:59 2016	(r300472)
+++ stable/10/usr.bin/ncal/ncal.c	Mon May 23 05:45:52 2016	(r300473)
@@ -642,8 +642,8 @@ monthrangeb(int y, int m, int jd_flag, i
 				wprintf(L"%-*ls  ",
 				    mw, wcenter(ws, year[i].name, mw));
 			else {
-				swprintf(ws, sizeof(ws), L"%-ls %d",
-				    year[i].name, M2Y(m + i));
+				swprintf(ws, sizeof(ws)/sizeof(ws[0]),
+				    L"%-ls %d", year[i].name, M2Y(m + i));
 				wprintf(L"%-*ls  ", mw, wcenter(ws1, ws, mw));
 			}
 		printf("\n");
@@ -958,7 +958,7 @@ mkweekdays(struct weekdays *wds)
 
 	for (i = 0; i != 7; i++) {
 		tm.tm_wday = (i+1) % 7;
-		wcsftime(buf, sizeof(buf), L"%a", &tm);
+		wcsftime(buf, sizeof(buf)/sizeof(buf[0]), L"%a", &tm);
 		for (len = 2; len > 0; --len) {
 			if ((width = wcswidth(buf, len)) <= 2)
 				break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605230545.u4N5jqLc094915>