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

Return value not checked for rename() #4589

Closed
michaelrsweet opened this issue Feb 24, 2015 · 2 comments
Closed

Return value not checked for rename() #4589

michaelrsweet opened this issue Feb 24, 2015 · 2 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 2.1-current
CUPS.org User: twaugh.redhat

In some instances, rename() is called without checking its return value. Here are the fixes for some of those.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"0001-Check-return-value-when-calling-rename.patch":

From 47a8d10f130312ef3e3dc4af2870f42ef53ca5e7 Mon Sep 17 00:00:00 2001
From: Tim Waugh [email protected]
Date: Tue, 24 Feb 2015 10:24:50 +0000
Subject: [PATCH] Check return value when calling rename().


scheduler/ipp.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index d775fb7..0c84a6c 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -8257,7 +8257,17 @@ print_job(cupsd_client_t con, / I - Client connection */

snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot, job->id,
job->num_files);

  • rename(con->filename, filename);
  • if (rename(con->filename, filename))
  • {
  • cupsdLogJob(job, CUPSD_LOG_ERROR,
  •   "Unable to rename job document file: %s",
    
  •   strerror(errno));
    
  • send_ipp_status(con, IPP_INTERNAL_ERROR,
  •       _("Unable to rename job document file."));
    
  • return;
  • }

cupsdClearString(&con->filename);

/*
@@ -9485,7 +9495,16 @@ send_document(cupsd_client_t con, / I - Client connection */

snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot, job->id,
job->num_files);

  • rename(con->filename, filename);
  • if (rename(con->filename, filename))
  • {
  • cupsdLogJob(job, CUPSD_LOG_ERROR,
  •   "Unable to rename job document file: %s",
    
  •   strerror(errno));
    
  • send_ipp_status(con, IPP_INTERNAL_ERROR,
  •       _("Unable to rename job document file."));
    
  • return;
  • }

cupsdClearString(&con->filename);

2.1.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