Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistake in log rotation code for devices #2278

Closed
michaelrsweet opened this issue Mar 6, 2007 · 3 comments
Closed

Mistake in log rotation code for devices #2278

michaelrsweet opened this issue Mar 6, 2007 · 3 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.2.8
CUPS.org User: twaugh.redhat

Found this by code inspection. At the point of this check, *logname=='\0' because we went through the format string loop. The string we want to check against is filename.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

I've committed a slightly different fix so that logname is not changed in the function...

@michaelrsweet
Copy link
Collaborator Author

"cups-typo.patch":

--- cups-1.2.8/scheduler/log.c.typo 2007-03-06 18:28:05.000000000 +0000
+++ cups-1.2.8/scheduler/log.c 2007-03-06 18:28:07.000000000 +0000
@@ -515,7 +515,7 @@

  • Do we need to rotate the log?
    */
  • if (strncmp(logname, "/dev/", 5) && cupsFileTell(*lf) > MaxLogSize &&
  • if (strncmp(filename, "/dev/", 5) && cupsFileTell(lf) > MaxLogSize &&
    MaxLogSize > 0)
    {
    /

@michaelrsweet
Copy link
Collaborator Author

"str2278.patch":

Index: log.c

--- log.c (revision 6326)
+++ log.c (working copy)
@@ -465,9 +465,10 @@
check_log_file(cups_file_t *lf, / IO - Log file /
const char *logname) /
I - Log filename */
{

  • char backname[1024], /* Backup log filename */
  • filename[1024], /* Formatted log filename */
  • ptr; / Pointer into filename */
  • char backname[1024], /* Backup log filename */
  •   filename[1024],     /\* Formatted log filename */
    
  •   _ptr;           /_ Pointer into filename */
    
  • const char logptr; / Pointer into log filename */

/*
@@ -499,17 +500,17 @@
else
filename[0] = '\0';

  • for (ptr = filename + strlen(filename);

  •     *logname && ptr < (filename + sizeof(filename) - 1);
    
  • logname ++)

  •  if (*logname == '%')
    
  • for (logptr = logname, ptr = filename + strlen(filename);

  •     *logptr && ptr < (filename + sizeof(filename) - 1);
    
  • logptr ++)

  •  if (*logptr == '%')
    

    {
    /*
    * Format spec...
    */

  •    logname ++;
    
  • if (*logname == 's')

  •    logptr ++;
    
  • if (logptr == 's')
    {
    /

  • Insert the server name...
    @@ -524,11 +525,11 @@

  • Otherwise just insert the character...
    */

  • *ptr++ = *logname;
    
  • *ptr++ = *logptr;
    

    }
    }
    else

  • *ptr++ = *logname;

  • *ptr++ = *logptr;

*ptr = '\0';
}

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

No branches or pull requests

1 participant