69e49a8551
A long due update with important features such as long filenames, unicode, etc. From new maintainer "Arnaud Bergeron" <abergeron@gmail.com>
85 lines
3.1 KiB
Plaintext
85 lines
3.1 KiB
Plaintext
$OpenBSD: patch-etc_papd_lp_c,v 1.1 2006/09/22 05:56:25 pvalchev Exp $
|
|
--- etc/papd/lp.c.orig Tue Jun 8 22:24:47 2004
|
|
+++ etc/papd/lp.c Sat Dec 31 01:31:29 2005
|
|
@@ -377,7 +377,7 @@ int lp_init( out, sat )
|
|
FILE *cap_file;
|
|
|
|
memset( auth_string, 0, 256 );
|
|
- sprintf(addr_filename, "%s/net%d.%dnode%d",
|
|
+ snprintf(addr_filename, sizeof(addr_filename), "%s/net%d.%dnode%d",
|
|
printer->p_authprintdir, addr_net/256, addr_net%256,
|
|
addr_node);
|
|
if (stat(addr_filename, &cap_st) == 0) {
|
|
@@ -489,7 +489,7 @@ int lp_init( out, sat )
|
|
lp.lp_seq = n;
|
|
|
|
n = ( n + 1 ) % 1000;
|
|
- sprintf( buf, "%03d\n", n );
|
|
+ snprintf( buf, sizeof(buf), "%03d\n", n );
|
|
lseek( fd, 0L, 0 );
|
|
write( fd, buf, strlen( buf ));
|
|
close( fd );
|
|
@@ -558,7 +558,7 @@ int lp_open( out, sat )
|
|
}
|
|
LOG(log_debug, logtype_papd, "lp_open: opened %s", pipexlate(printer->p_printer) );
|
|
} else {
|
|
- sprintf( name, "df%c%03d%s", lp.lp_letter++, lp.lp_seq, hostname );
|
|
+ snprintf( name, sizeof(name), "df%c%03d%s", lp.lp_letter++, lp.lp_seq, hostname );
|
|
|
|
if (( fd = open( name, O_WRONLY|O_CREAT|O_EXCL, 0660 )) < 0 ) {
|
|
LOG(log_error, logtype_papd, "lp_open %s: %m", name );
|
|
@@ -719,7 +719,7 @@ int lp_cancel()
|
|
}
|
|
|
|
for ( letter = 'A'; letter < lp.lp_letter; letter++ ) {
|
|
- sprintf( name, "df%c%03d%s", letter, lp.lp_seq, hostname );
|
|
+ snprintf( name, sizeof(name), "df%c%03d%s", letter, lp.lp_seq, hostname );
|
|
if ( unlink( name ) < 0 ) {
|
|
LOG(log_error, logtype_papd, "lp_cancel unlink %s: %m", name );
|
|
}
|
|
@@ -753,7 +753,7 @@ int lp_print()
|
|
|
|
if ( printer->p_flags & P_SPOOLED ) {
|
|
#ifndef HAVE_CUPS
|
|
- sprintf( tfname, "tfA%03d%s", lp.lp_seq, hostname );
|
|
+ snprintf( tfname, sizeof(tfname), "tfA%03d%s", lp.lp_seq, hostname );
|
|
if (( fd = open( tfname, O_WRONLY|O_EXCL|O_CREAT, 0660 )) < 0 ) {
|
|
LOG(log_error, logtype_papd, "lp_print %s: %m", tfname );
|
|
return 0;
|
|
@@ -798,7 +798,7 @@ int lp_print()
|
|
}
|
|
fclose( cfile );
|
|
|
|
- sprintf( cfname, "cfA%03d%s", lp.lp_seq, hostname );
|
|
+ snprintf( cfname, sizeof(cfname), "cfA%03d%s", lp.lp_seq, hostname );
|
|
if ( link( tfname, cfname ) < 0 ) {
|
|
LOG(log_error, logtype_papd, "lp_print can't link %s to %s: %m", cfname,
|
|
tfname );
|
|
@@ -811,7 +811,7 @@ int lp_print()
|
|
return 0;
|
|
}
|
|
|
|
- sprintf( buf, "\1%s\n", printer->p_printer );
|
|
+ snprintf( buf, sizeof(buf), "\1%s\n", printer->p_printer );
|
|
n = strlen( buf );
|
|
if ( write( s, buf, n ) != n ) {
|
|
LOG(log_error, logtype_papd, "lp_print write: %m" );
|
|
@@ -944,7 +944,7 @@ int lp_rmjob( job )
|
|
return( -1 );
|
|
}
|
|
|
|
- sprintf( buf, "\5%s %s %d\n", printer->p_printer, lp.lp_person, job );
|
|
+ snprintf( buf, sizeof(buf), "\5%s %s %d\n", printer->p_printer, lp.lp_person, job );
|
|
n = strlen( buf );
|
|
if ( write( s, buf, n ) != n ) {
|
|
LOG(log_error, logtype_papd, "lp_rmjob write: %m" );
|
|
@@ -982,7 +982,7 @@ int lp_queue( out )
|
|
return( -1 );
|
|
}
|
|
|
|
- sprintf( buf, "\3%s\n", printer->p_printer );
|
|
+ snprintf( buf, sizeof(buf), "\3%s\n", printer->p_printer );
|
|
n = strlen( buf );
|
|
if ( write( s, buf, n ) != n ) {
|
|
LOG(log_error, logtype_papd, "lp_queue write: %m" );
|