[cups.bugs] [MOD] STR #1263: lpstat prints random data
kssingvo.suse
kssingvo at suse.de
Mon Sep 5 00:41:20 PDT 2005
[STR New]
Running SUSE Linux... :-)
We noticed that under certain locale variables lpstat shows garbage:
------------------------------------------------------------------------------
pluto:~# env LC_TIME=en_US.UTF-8 lpstat -t
scheduler is running
system default destination: laserjet2200
device for laserjet2200: hp:/usb/HP_LaserJet_2200?device=/dev/usb/lp0
laserjet2200 accepting requests since Jan 01 00:00
printer laserjet2200 disabled since Jan 01 00:00 -
Paused
laserjet2200-3 kssingvo 1024 ž¿
laserjet2200-4 kssingvo 78848 ž¿
------------------------------------------------------------------------------
pluto:~ # env LC_TIME=en_GB.UTF-8 lpstat -t
scheduler is running
system default destination: laserjet2200
device for laserjet2200: hp:/usb/HP_LaserJet_2200?device=/dev/usb/lp0
laserjet2200 accepting requests since Jan 01 00:00
printer laserjet2200 disabled since Jan 01 00:00 -
Paused
laserjet2200-3 kssingvo 1024 Fri 02 Sep 2005 12:52:06
CEST
laserjet2200-4 kssingvo 78848 Fri 02 Sep 2005 13:17:41
CEST
------------------------------------------------------------------------------
The difference is, that strftime(... "%c" ...) wants to write more than 32
characters into array date[], if called with LC_TIME=en_US.UTF-8: There is
an "A.M." / "P.M." extension in the output string.
So, I think the problematic part is the limited array length of date[]:
char date[32];
[...]
strftime(date, sizeof(date), CUPS_STRFTIME_FORMAT, jobdate);
The manual of strftime(3) says:
------------------------------------------------------------------------------
The strftime() function returns the number of characters placed in the
array s, not including the terminating NUL character, provided the
string, including the terminating NUL, fits. Otherwise, it returns 0,
and the contents of the array is undefined. (Thus at least since libc
4.4.4; very old versions of libc, such as libc 4.4.1, would return max
if the array was too small.)
------------------------------------------------------------------------------
So, it looks like this is a glibc (I tested 2.3.5) specific problem.
Nevertheless it is a problem for this kind of OS.
I attache our fix, but maybe it would be better to put an "unknown" into
date[] array before calling strftime(), to have at least a defined value?
If the later, we should do this before any call of strftime() in the CUPS
code.
Related: https://bugzilla.novell.com/show_bug.cgi?id=105732
Link: http://www.cups.org/str.php?L1263
Version: 1.1.23
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cups-1.1.23-lpstat_strftime.patch
URL: <http://lists.cups.org/pipermail/cups-devel/attachments/20050905/7d5985e0/attachment.ksh>
More information about the cups-devel
mailing list