summaryrefslogtreecommitdiff
path: root/usr.bin/ncal
diff options
context:
space:
mode:
authorDon Lewis <truckman@FreeBSD.org>2016-05-17 05:05:30 +0000
committerDon Lewis <truckman@FreeBSD.org>2016-05-17 05:05:30 +0000
commitb74e3739712864e2cb7970e6435ab601446efbe3 (patch)
tree07c5e4456b245209527a53fabc2c04ecccfa5c0f /usr.bin/ncal
parente5d4b0faa586a1755f129945d30736703b3c894a (diff)
downloadsrc-test-b74e3739712864e2cb7970e6435ab601446efbe3.tar.gz
src-test-b74e3739712864e2cb7970e6435ab601446efbe3.zip
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 MFC after: 1 week
Notes
Notes: svn path=/head/; revision=300005
Diffstat (limited to 'usr.bin/ncal')
-rw-r--r--usr.bin/ncal/ncal.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/ncal/ncal.c b/usr.bin/ncal/ncal.c
index 48b8c1ae0f562..5a5cbc3553abf 100644
--- a/usr.bin/ncal/ncal.c
+++ b/usr.bin/ncal/ncal.c
@@ -642,8 +642,8 @@ monthrangeb(int y, int m, int jd_flag, int before, int after)
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;