BUG #660 -- problem solved?

Torsten tkali at bredex.de
Wed Dec 17 18:27:30 GMT 2003


Hello List!

I have been looking / debugging a problem with samba and printing on
solaris.

Please find attached a patch for 3.0.1 (that at least works for me).
The baisc problem seems to be a different output format for lpq on 
Solaris, so I have used "bsd"-style printing in my smb.conf. I also 
fixed the parsing of the lpq-output.


-- Torsten.
-------------- next part --------------
--- lib/util_str.c.orig	Wed Dec 17 09:23:22 2003
+++ lib/util_str.c	Wed Dec 17 09:03:37 2003
@@ -47,6 +47,9 @@
 
 	s = (char *)*ptr;
 
+	if (!s) 
+	    return(False);
+
 	/* default to simple separators */
 	if (!sep)
 		sep = " \t\n\r";
--- printing/lpq_parse.c.orig	Tue Dec 16 10:38:40 2003
+++ printing/lpq_parse.c	Wed Dec 17 11:29:48 2003
@@ -99,7 +99,7 @@
 #define	JOBTOK	3
 #define	FILETOK	4
 #define	TOTALTOK (count - 2)
-#define	NTOK	6
+#define	NTOK	7 /* start counting from 0, seven entries and last one is NULL */
 #define	MAXTOK	128
 #else	/* OSF1 */
 #define	RANKTOK	0
@@ -107,12 +107,13 @@
 #define	JOBTOK	2
 #define	FILETOK	3
 #define	TOTALTOK (count - 2)
-#define	NTOK	5
+#define	NTOK	6 /* start counting from 0, six entries and last one is NULL */
 #define	MAXTOK	128
 #endif	/* OSF1 */
 
-  char *tok[MAXTOK];
+  fstring tok[MAXTOK];
   int  count = 0;
+  int i;
   pstring line2;
 
   pstrcpy(line2,line);
@@ -126,16 +127,13 @@
   }
 #endif	/* OSF1 */
 
-  /* FIXME: Use next_token rather than strtok! */
-
-  tok[0] = strtok(line2," \t");
-  count++;
+  {
+     const char* cline2 = line2;
 
-  while (((tok[count] = strtok(NULL," \t")) != NULL) && (count < MAXTOK)) {
-    count++;
+     for (count=0; count<MAXTOK && next_token(&cline2,tok[count],NULL,sizeof(tok[count])); count++);
+     
   }
+
 
   /* we must get at least NTOK tokens */
   if (count < NTOK)
--- printing/printing.c.orig	Wed Dec 17 13:11:16 2003
+++ printing/printing.c	Wed Dec 17 13:19:00 2003
@@ -2125,10 +2125,8 @@
 	/* Get the stored queue data. */
 	data = tdb_fetch(pdb->tdb, key);
 
-	if (data.dptr == NULL || data.dsize < 4)
-		qcount = 0;
-	else
-		memcpy(&qcount, data.dptr, 4);
+	if ( (data.dptr) && (data.dsize >= sizeof(qcount)) ) 
+	    len += tdb_unpack(data.dptr + len, data.dsize - len, "d", &qcount);
 
 	/* Get the changed jobs list. */
 	key.dptr = "INFO/jobs_changed";
@@ -2148,10 +2146,9 @@
 		goto out;
 
 	/* Retrieve the linearised queue data. */
-	len = 0;
 	for( i  = 0; i < qcount; i++) {
 		uint32 qjob, qsize, qpage_count, qstatus, qpriority, qtime;
-		len += tdb_unpack(data.dptr + 4 + len, data.dsize - len, "ddddddff",
+		len += tdb_unpack(data.dptr + len, data.dsize - len, "ddddddff",
 				&qjob,
 				&qsize,
 				&qpage_count,


More information about the samba-technical mailing list