/*
- * $Id: afp_config.c,v 1.22.6.9.2.3 2005-09-27 10:40:40 didg Exp $
+ * $Id: afp_config.c,v 1.22.6.9.2.4 2009-02-03 08:25:00 didg Exp $
*
* Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
* All Rights Reserved. See COPYRIGHT.
{
FILE *fp;
char buf[LINESIZE + 1], *p, have_option = 0;
+ size_t len;
struct afp_options options;
AFPConfig *config=NULL, *first = NULL;
LOG(log_debug, logtype_afpd, "Loading ConfigFile");
/* scan in the configuration file */
+ len = 0;
while (!feof(fp)) {
- if (!fgets(buf, sizeof(buf), fp) || buf[0] == '#')
+ if (!fgets(&buf[len], LINESIZE - len, fp) || buf[len] == '#')
continue;
+ len = strlen(buf);
+ if ( len >= 2 && buf[len-2] == '\\' ) {
+ len -= 2;
+ continue;
+ } else
+ len = 0;
/* a little pre-processing to get rid of spaces and end-of-lines */
p = buf;
/*
- * $Id: volume.c,v 1.51.2.7.2.33.2.22 2009-02-01 07:00:12 didg Exp $
+ * $Id: volume.c,v 1.51.2.7.2.33.2.23 2009-02-03 08:25:00 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
p = buf;
while ((EOF != ( c = getc( fp )) ) && ( size > 1 )) {
if ( c == '\n' || c == '\r' ) {
+ if (p != buf && *(p -1) == '\\') {
+ p--;
+ size++;
+ continue;
+ }
*p++ = '\n';
break;
} else {
/*
- * $Id: auth.c,v 1.6.8.2.2.2 2005-03-11 15:36:59 didg Exp $
+ * $Id: auth.c,v 1.6.8.2.2.3 2009-02-03 08:25:00 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
char name[MAXPATHLEN + 1], buf[MAXPATHLEN + 1], *p;
struct uam_mod *mod;
struct stat st;
- int len;
+ size_t len;
if (!path || !list || (len = strlen(path)) > sizeof(name) - 2)
return -1;
/*
- * $Id: file.c,v 1.9 2002-01-04 04:45:47 sibaz Exp $
+ * $Id: file.c,v 1.9.12.1 2009-02-03 08:25:00 didg Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#include "file.h"
+/*
+*/
int markline( pf, start, linelength, crlflength )
char **start;
int *linelength, *crlflength;
(p[*crlflength]=='\r' || p[*crlflength]=='\n')) {
(*crlflength)++;
}
+
+ if (!*crlflength) {
+ /* line is way too long, something fishy is going on, give up */
+ LOG(log_error, logtype_papd, "markline: no crlf in comment, give up" );
+ return( -2 );
+ }
/* success, return 1 */
return( 1 );
/*
- * $Id: headers.c,v 1.9.10.1.2.3 2008-08-14 19:58:27 didg Exp $
+ * $Id: headers.c,v 1.9.10.1.2.4 2009-02-03 08:25:00 didg Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
cmt = get_text(start, linelength);
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
#ifdef DEBUG
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
cmt = get_text(start, linelength);
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
in->pf_state |= PF_TRANSLATE;
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
in->pf_state |= PF_TRANSLATE;
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
lp_write( in, start, linelength + crlflength );
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
in->pf_state |= PF_TRANSLATE;
/*
- * $Id: lp.c,v 1.14.8.4.2.6 2009-01-21 02:33:55 didg Exp $
+ * $Id: lp.c,v 1.14.8.4.2.7 2009-02-03 08:25:00 didg Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
}
-int lp_init( out, sat )
+static int lp_init( out, sat )
struct papfile *out;
struct sockaddr_at *sat;
{
}
if ( lp.lp_flags & LP_PIPE ) {
+ char *pipe_cmd;
/* go right to program */
if (lp.lp_person != NULL) {
if((pwent = getpwnam(lp.lp_person)) != NULL) {
if(setreuid(pwent->pw_uid, pwent->pw_uid) != 0) {
- LOG(log_info, logtype_papd, "setreuid error: %s", strerror(errno));
+ LOG(log_error, logtype_papd, "setreuid error: %s", strerror(errno));
+ exit(1);
}
} else {
- LOG(log_info, logtype_papd, "Error getting username (%s)", lp.lp_person);
+ LOG(log_error, logtype_papd, "Error getting username (%s)", lp.lp_person);
+ exit(1);
}
}
lp_setup_comments(CH_UNIX);
- if (( lp.lp_stream = popen( pipexlate(printer->p_printer), "w" )) == NULL ) {
+ pipe_cmd = pipexlate(printer->p_printer);
+ if (( lp.lp_stream = popen(pipe_cmd, "w" )) == NULL ) {
LOG(log_error, logtype_papd, "lp_open popen %s: %s", printer->p_printer, strerror(errno) );
spoolerror( out, NULL );
return( -1 );
}
- LOG(log_debug, logtype_papd, "lp_open: opened %s", pipexlate(printer->p_printer) );
+ LOG(log_debug, logtype_papd, "lp_open: opened %s", pipe_cmd );
} else {
sprintf( name, "df%c%03d%s", lp.lp_letter++, lp.lp_seq, hostname );
/*
- * $Id: lp.h,v 1.3.14.1 2004-06-09 01:25:53 bfernhomberg Exp $
+ * $Id: lp.h,v 1.3.14.1.2.1 2009-02-03 08:25:00 didg Exp $
*/
#ifndef PAPD_LP_H
int lp_rmjob __P(( int ));
int lp_queue __P(( struct papfile * ));
-/* initialize printing interface */
-int lp_init __P(( struct papfile *, struct sockaddr_at * ));
/* cancel current job */
int lp_cancel __P(( void ));
/* print current job */
/*
- * $Id: magics.c,v 1.11.6.2.2.2 2005-09-27 10:40:41 didg Exp $
+ * $Id: magics.c,v 1.11.6.2.2.3 2009-02-03 08:25:00 didg Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
static int state=0;
+static void parser_error(outfile)
+ struct papfile *outfile;
+{
+ spoolerror( outfile, "Comments error, Ignoring job." );
+ outfile->pf_state |= PF_EOF;
+ lp_close();
+}
+
int ps( infile, outfile, sat )
struct papfile *infile, *outfile;
struct sockaddr_at *sat;
case CH_MORE :
return( CH_MORE );
+ case CH_ERROR :
+ parser_error(outfile);
+ return( 0 );
+
default :
return( CH_ERROR );
}
lp_close();
return( 0 );
+ case -2:
+ parser_error(outfile);
+ return( 0 );
+
case -1 :
return( 0 );
}
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
if ( in->pf_state & PF_BOT ) {
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
if ( in->pf_state & PF_BOT ) {
in->pf_state &= ~PF_BOT;
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
stop = start + linelength;
}
}
- if ( stop - p >= strlen( Query ) &&
+ if ( (size_t)(stop - p) >= strlen( Query ) &&
strncmp( p, Query, strlen( Query )) == 0 ) {
if ( comswitch( magics, cm_psquery ) < 0 ) {
LOG(log_error, logtype_papd, "cm_psswitch: can't find psquery!" );
/*
- * $Id: main.c,v 1.18.6.2.2.6 2009-01-21 04:07:05 didg Exp $
+ * $Id: main.c,v 1.18.6.2.2.7 2009-02-03 08:25:00 didg Exp $
*
* Copyright (c) 1990,1995 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
LOG(log_error, logtype_papd, "sigaction: %s", strerror(errno) );
exit( 1 );
}
+
+ if ( sigaction( SIGCHLD, &sv, 0 ) < 0 ) {
+ LOG(log_error, logtype_papd, "sigaction: %s", strerror(errno) );
+ exit( 1 );
+ }
for ( pr = printers; pr; pr = pr->p_next ) {
atp_close( pr->p_atp );
/*
- * $Id: ppd.c,v 1.9.8.1.2.6 2009-01-21 04:07:05 didg Exp $
+ * $Id: ppd.c,v 1.9.8.1.2.7 2009-02-03 08:25:00 didg Exp $
*
* Copyright (c) 1995 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
}
#endif /* SHOWPPD */
+ if (len > sizeof(ppd_feature_main) -1)
+ return( NULL );
+
for ( end = feature + len, p = feature, q = ppd_feature_main;
(p <= end) && (*p != '\n') && (*p != '\r'); p++, q++ ) {
*q = *p;
/*
- * $Id: queries.c,v 1.16.2.1.2.1.2.1 2005-02-06 10:16:02 didg Exp $
+ * $Id: queries.c,v 1.16.2.1.2.1.2.2 2009-02-03 08:25:00 didg Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
stop = start+linelength;
break;
}
}
- p++;
- while ( *p == ' ' ) {
+ if (p < stop) {
p++;
+ while ( *p == ' ' ) {
+ p++;
+ }
}
append( out, p, stop - p + crlflength );
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
p = start + strlen( comment->c_begin );
bzero( &tkt, sizeof( tkt ));
stop = start+linelength;
+ /* FIXME */
for ( i = 0, t = tkt.dat; p < stop; p += 2, t++, i++ ) {
*t = ( h2b( (unsigned char)*p ) << 4 ) +
h2b( (unsigned char)*( p + 1 ));
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
if ( comgetflags() == 0 ) { /* start */
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
stop = start+linelength;
}
}
- for ( p++; p < stop; p++ ) {
+ if (p < stop) for ( p++; p < stop; p++ ) {
if ( *p != ' ' && *p != '\t' ) {
break;
}
}
for ( gq = genqueries; gq->gq_name; gq++ ) {
- if (( strlen( gq->gq_name ) == q - p ) &&
+ if (( strlen( gq->gq_name ) == (size_t)(q - p) ) &&
( strncmp( gq->gq_name, p, q - p ) == 0 )) {
break;
}
p = start;
while ( p < stop ) {
+ unsigned int count = 0;
while (( *p == ' ' || *p == '\t' ) && p < stop ) {
p++;
}
q = buf;
while ( *p != ' ' && *p != '\t' &&
- *p != '\n' && *p != '\r' && p < stop ) {
+ *p != '\n' && *p != '\r' && p < stop && count < sizeof(buf)) {
*q++ = *p++;
+ count++;
}
if ( q != buf ) {
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
stop = start + linelength;
break;
}
}
- p++;
+ if (p < stop)
+ p++;
cq_font_answer( p, stop, out );
} else {
break;
}
}
- p++;
+ if (p < stop)
+ p++;
cq_font_answer( p, stop, out );
} else {
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
stop = start + linelength;
break;
}
}
- p++;
+ if (p < stop)
+ p++;
while ( *p == ' ' ) {
p++;
}
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
if ( comgetflags() == 0 ) {
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
stop = start + linelength;
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
if ( lp_queue( out )) {
int linelength, crlflength;
char username[UAM_USERNAMELEN + 1] = "\0";
struct papd_comment *comment = compeek();
- char uamtype[20] = "\0";
+ char uamtype[20];
for (;;) {
switch ( markline( in, &start, &linelength, &crlflength )) {
case -1 :
return( CH_MORE );
+
+ case -2 :
+ return( CH_ERROR );
}
stop = start + linelength;
begin = start + strlen(comment->c_begin);
p = begin;
- while (*p != ' ') {
+ while (*p != ' ' && p < stop) {
p++;
}
- strncat(uamtype, begin, p - begin);
+ memset(uamtype, 0, sizeof(uamtype));
+ if ((size_t)(p -begin) <= sizeof(uamtype) -1) {
+ strncpy(uamtype, begin, p - begin);
+ }
- if ((papd_uam = auth_uamfind(UAM_SERVER_PRINTAUTH,
+ if ( !*uamtype || (papd_uam = auth_uamfind(UAM_SERVER_PRINTAUTH,
uamtype, strlen(uamtype))) == NULL) {
LOG(log_info, logtype_papd, "Could not find uam: %s", uamtype);
append(out, rbiloginbad, strlen(rbiloginbad));