Byte order problem in spoolss

Benjamin Kuit bj at it.uts.edu.au
Fri Jan 25 06:06:06 GMT 2002


Earlier today I wrote in an email mentioning that my print queues
doesn't show up submitted times of jobs, yet the time can be seen when
you select the job and right-click for it's properties. I'm running
Solaris on a sparc workstation.

Just confirmed that it's a byte-order problem and I've included
a possible fix (or hack) for it.

In spoolss_notify_submitted_time (rpc_server/srv_spoolss_nt.c),
the SYSTEMTIME structure (which is several uint16 values) is filled
with the respective date, and then the contents of the structure is
memcpy'd into the info_data stream, without regard to byte order.
So I guess samba was telling my workstation that the jobs were
submitted in year 53767?.

The problem doesn't exist when you right-click for job properties,
because that time is parsed in though other routines, like
spoolss_io_system_time(), which is apparently getting the byte order
right.

Bj

-- 
+-------------------------------+--------------------------------------+
|      Benjamin (Bj) Kuit       |  Building 4, 447                     |
|      Systems Programmer       |  Faculty of Information Technology   |
|      Phone: 02 9514 1841      |  University of Technology, Sydney    |
|      Mobile: 0416 184 972     |  Email: bj at it.uts.edu.au             |
+-------------------------------+--------------------------------------+
-------------- next part --------------
--- rpc_server/srv_spoolss_nt.c.fixSubmittedTime.orig	Sat Jan 26 00:25:57 2002
+++ rpc_server/srv_spoolss_nt.c	Sat Jan 26 00:53:32 2002
@@ -2044,12 +2044,14 @@
 	struct tm *t;
 	uint32 len;
 	SYSTEMTIME st;
+	int i;
 
 	t=gmtime(&queue->time);
 
 	len = sizeof(SYSTEMTIME);
 
-	data->notify_data.data.length = len/2 - 1;
+	/* Number of uint16 entries in SYSTEMTIME */
+	data->notify_data.data.length = len/sizeof(uint16);
 	data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
 
 	if (!data->notify_data.data.string) {
@@ -2058,7 +2060,9 @@
 	}
 	
 	make_systemtime(&st, t);
-	memcpy(data->notify_data.data.string,&st,len);
+	for (i=0;i<data->notify_data.data.length;i++) {
+		SSVAL(data->notify_data.data.string+i,0,((uint16 *)&st)[i]);
+	}
 }
 
 #define END 65535


More information about the samba-technical mailing list