cups/auth.c ignoring return value of 'fgets' error #4293

Closed
michaelrsweet opened this Issue Mar 13, 2013 · 6 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Mar 13, 2013

Version: 1.6-current
CUPS.org User: dkosovic

With the current 1.6 SVN branch, cups/auth.c has the following error (on RHEL6.3) because the return value of a 'fgets' call isn't being assigned to a variable or being used :

Compiling auth.c...
gcc -Wshadow -Werror -Wall -Wno-format-y2k -Wunused -fPIC -g -fstack-protector -D_GNU_SOURCE -I.. -D_CUPS_SOURCE -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -fstack-protector-all -DLDAP_DEPRECATED=1 -I/usr/include/libusb-1.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -DDBUS_API_SUBJECT_TO_CHANGE -DOPENSSL_DISABLE_OLD_DES_SUPPORT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT -c -o auth.o auth.c
cc1: warnings being treated as errors
auth.c: In function 'cups_local_auth':
auth.c:858: error: ignoring return value of 'fgets', declared with attribute warn_unused_result
make: *** [auth.o] Error 1

Collaborator

michaelrsweet commented Mar 13, 2013

CUPS.org User: dkosovic

As a workaround I removed the .svn directory as config-scripts/cups-compiler.m4 had a conditional with the following:

# Additional warning options for development testing...
if test -d .svn; then
        OPTIM="-Wshadow -Werror $OPTIM"

now have the following error which I'm guessing needs an #ifdef HAVE_CDSASSL:

make[1]: Entering directory `/root/rpmbuild/BUILD/cups-1.6svn-r10903/cups'
echo Compiling http.c...
Compiling http.c...
gcc -Wall -Wno-format-y2k -Wunused -fPIC -g -fstack-protector -Wno-tautological-compare -D_GNU_SOURCE -I.. -D_CUPS_SOURCE -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -fstack-protector-all -DLDAP_DEPRECATED=1 -I/usr/include/libusb-1.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -DDBUS_API_SUBJECT_TO_CHANGE -DOPENSSL_DISABLE_OLD_DES_SUPPORT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT -c -o http.o http.c
http.c: In function 'http_setup_ssl':
http.c:3946: error: 'cg' undeclared (first use in this function)
http.c:3946: error: (Each undeclared identifier is reported only once
http.c:3946: error: for each function it appears in.)

Collaborator

michaelrsweet commented Mar 13, 2013

CUPS.org User: dkosovic

Fixed the undeclared 'cg' error by moving the line with the following 'cg' declaration outside of an #elif defined(HAVE_CDSASSL) preprocessor conditional to where it was previously. Patch attached.

_cups_globals_t *cg = _cupsGlobals();

Collaborator

michaelrsweet commented Mar 13, 2013

CUPS.org User: mike

In practice this is not a real issue, but we will add a NULL check here and "do the right thing."

Collaborator

michaelrsweet commented Mar 13, 2013

CUPS.org User: mike

Fixed in Subversion repository.

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

Collaborator

michaelrsweet commented Mar 13, 2013

"str4293.patch":

Index: cups/auth.c

--- cups/auth.c (revision 10901)
+++ cups/auth.c (working copy)
@@ -667,8 +667,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 */
    @@ -862,19 +861,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);

Collaborator

michaelrsweet commented Mar 13, 2013

"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);

michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment