Re: [MOD] STR #4293: cups/auth.c ignoring return value of 'fgets' error

Michael Sweet <[email protected]> Wed, 13 Mar 2013 09:27:32 -0700 (PDT)
Newsgroups gmane.comp.printing.cups.bugs
Message-ID <[email protected]>

--PART-BOUNDARY
Content-Type: text/plain

DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR Closed w/Resolution]

Fixed in Subversion repository.

The 1.6 version of the patch includes the small fix for http.c's
http_setup_ssl function.

Link: https://www.cups.org/str.php?L4293
Version: 1.6-current
Fix Version: 1.7-current (r10904)
--PART-BOUNDARY
Content-Type: text/plain
Content-Disposition: attachment; filename="str4293-1.6.patch"

Index: cups/http.c
===================================================================
--- cups/http.c	(revision 10903)
+++ cups/http.c	(working copy)
@@ -3,7 +3,7 @@
  *
  *   HTTP routines for CUPS.
  *
- *   Copyright 2007-2012 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   This file contains Kerberos support code, copyright 2006 by
@@ -3895,7 +3895,8 @@
   int			any_root;	/* Allow any root */
   char			hostname[256],	/* Hostname */
 			*hostptr;	/* Pointer into hostname */
-
+  _cups_globals_t	*cg = _cupsGlobals();
+					/* Pointer to library globals */
 #  ifdef HAVE_LIBSSL
   SSL_CTX		*context;	/* Context for encryption */
   BIO			*bio;		/* BIO data */
@@ -3905,8 +3906,6 @@
   gnutls_certificate_client_credentials *credentials;
 					/* TLS credentials */
 #  elif defined(HAVE_CDSASSL)
-  _cups_globals_t	*cg = _cupsGlobals();
-					/* Pointer to library globals */
   OSStatus		error;		/* Error code */
   const char		*message = NULL;/* Error message */
 #    ifdef HAVE_SECCERTIFICATECOPYDATA
Index: cups/auth.c
===================================================================
--- cups/auth.c	(revision 10903)
+++ cups/auth.c	(working copy)
@@ -3,7 +3,7 @@
  *
  *   Authentication functions for CUPS.
  *
- *   Copyright 2007-2012 by Apple Inc.
+ *   Copyright 2007-2013 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   This file contains Kerberos support code, copyright 2006 by
@@ -660,8 +660,7 @@
   int			pid;		/* Current process ID */
   FILE			*fp;		/* Certificate file */
   char			trc[16],	/* Try Root Certificate parameter */
-			filename[1024],	/* Certificate filename */
-			certificate[33];/* Certificate string */
+			filename[1024];	/* Certificate filename */
   _cups_globals_t *cg = _cupsGlobals();	/* Global data */
 #  if defined(HAVE_AUTHORIZATION_H)
   OSStatus		status;		/* Status */
@@ -855,19 +854,25 @@
     * Read the certificate from the file...
     */
 
-    fgets(certificate, sizeof(certificate), fp);
+    char	certificate[33],	/* Certificate string */
+		*certptr;		/* Pointer to certificate string */
+
+    certptr = fgets(certificate, sizeof(certificate), fp);
     fclose(fp);
 
-   /*
-    * Set the authorization string and return...
-    */
+    if (certptr)
+    {
+     /*
+      * Set the authorization string and return...
+      */
 
-    httpSetAuthString(http, "Local", certificate);
+      httpSetAuthString(http, "Local", certificate);
 
-    DEBUG_printf(("8cups_local_auth: Returning authstring=\"%s\"",
-		  http->authstring));
+      DEBUG_printf(("8cups_local_auth: Returning authstring=\"%s\"",
+		    http->authstring));
 
-    return (0);
+      return (0);
+    }
   }
 
   return (1);

--PART-BOUNDARY
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
cups-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/cups-bugs

--PART-BOUNDARY--