1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-12 20:58:37 +03:00

Added Martin's lpq parse fixes from 2.2.

Jeremy.
(This used to be commit 3853234c2649c501e9876f940f802be86cb6383d)
This commit is contained in:
Jeremy Allison 2002-04-19 17:59:13 +00:00
parent 4f4d25d3e1
commit 16e1ff4f3a
2 changed files with 15 additions and 20 deletions

View File

@ -53,6 +53,9 @@
#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
#define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
#define fstrterminate(d) (((d)[sizeof(fstring)-1]) = '\0')
#define pstrterminate(d) (((d)[sizeof(pstring)-1]) = '\0')
#define wpstrcpy(d,s) safe_strcpy_w((d),(s),sizeof(wpstring))
#define wpstrcat(d,s) safe_strcat_w((d),(s),sizeof(wpstring))
#define wfstrcpy(d,s) safe_strcpy_w((d),(s),sizeof(wfstring))

View File

@ -149,21 +149,17 @@ static BOOL parse_lpq_bsd(char *line,print_queue_struct *buf,BOOL first)
StrnCpy(buf->fs_file,tok[FILETOK],sizeof(buf->fs_file)-1);
if ((FILETOK + 1) != TOTALTOK) {
int bufsize;
int i;
bufsize = sizeof(buf->fs_file) - strlen(buf->fs_file) - 1;
for (i = (FILETOK + 1); i < TOTALTOK; i++) {
safe_strcat(buf->fs_file," ",bufsize);
safe_strcat(buf->fs_file,tok[i],bufsize - 1);
bufsize = sizeof(buf->fs_file) - strlen(buf->fs_file) - 1;
if (bufsize <= 0) {
break;
}
/* FIXME: Using fstrcat rather than other means is a bit
* inefficient; this might be a problem for enormous queues with
* many fields. */
fstrcat(buf->fs_file, " ");
fstrcat(buf->fs_file, tok[i]);
}
/* Ensure null termination. */
buf->fs_file[sizeof(buf->fs_file)-1] = '\0';
fstrterminate(buf->fs_file);
}
#ifdef PRIOTOK
@ -282,21 +278,17 @@ static BOOL parse_lpq_lprng(char *line,print_queue_struct *buf,BOOL first)
StrnCpy(buf->fs_file,tokarr[LPRNG_FILETOK],sizeof(buf->fs_file)-1);
if ((LPRNG_FILETOK + 1) != LPRNG_TOTALTOK) {
int bufsize;
int i;
bufsize = sizeof(buf->fs_file) - strlen(buf->fs_file) - 1;
for (i = (LPRNG_FILETOK + 1); i < LPRNG_TOTALTOK; i++) {
safe_strcat(buf->fs_file," ",bufsize);
safe_strcat(buf->fs_file,tokarr[i],bufsize - 1);
bufsize = sizeof(buf->fs_file) - strlen(buf->fs_file) - 1;
if (bufsize <= 0) {
break;
}
/* FIXME: Using fstrcat rather than other means is a bit
* inefficient; this might be a problem for enormous queues with
* many fields. */
fstrcat(buf->fs_file, " ");
fstrcat(buf->fs_file, tokarr[i]);
}
/* Ensure null termination. */
buf->fs_file[sizeof(buf->fs_file)-1] = '\0';
fstrterminate(buf->fs_file);
}
return(True);