Comment 5 for bug 697213

Revision history for this message
Allison Randal (allison) wrote :

The Debian package patches the calendar source files to support Unicode in the form of wide characters (wchar_t) in place of traditional chars. In a few places, the patches don't completely replace the old char-like behavior, or too aggressively try to use wchar-like behavior on old-style char strings.

The attached patch (to the Debian quilt patches) fixes the buffer overflow, which was caused by using 'sizeof' (which returns a count of bytes) to calculate the maximum size passed to 'swprintf' (which expects the size as a count of wide characters). The patch also fixes some related warnings from the compile, also caused by incorrect handling of wchars:

io.c: In function ‘cal’:
io.c:133:6: warning: format ‘%ls’ expects type ‘wchar_t *’, but argument 3 has type ‘char *’
io.c:216:10: warning: passing argument 1 of ‘swprintf’ from incompatible pointer type
/usr/include/bits/wchar2.h:286:1: note: expected ‘wchar_t * __restrict__’ but argument is of type ‘wchar_t (*)[31]’
io.c:227:12: warning: passing argument 1 of ‘swprintf’ from incompatible pointer type
/usr/include/bits/wchar2.h:286:1: note: expected ‘wchar_t * __restrict__’ but argument is of type ‘wchar_t **’

I'll send these patches upstream to Debian.