From 2a9c96302bccd1b2bfa6ee1c75366fce9ff9ab4c Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Wed, 4 May 2022 08:10:46 -0400 Subject: [PATCH] No longer use O_RDWR for append mode (Issue #291) --- CHANGES.md | 2 ++ cups/file.c | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3d325ca560..050c41116a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ CHANGES - OpenPrinting CUPS 2.4.1 - 2022-01-27 Changes in CUPS v2.4.2 (TBA) ---------------------------- +- The `cupsFileOpen` function no longer opens files for append in read-write + mode (Issue #291) - The cupsd daemon removed processing temporary queue (Issue #364) - Fixed delay in IPP backend if GNUTLS is used and endpoint doesn't confirm closing the connection (Issue #365) diff --git a/cups/file.c b/cups/file.c index 14683fa020..48969e64aa 100644 --- a/cups/file.c +++ b/cups/file.c @@ -6,7 +6,7 @@ * our own file functions allows us to provide transparent support of * different line endings, gzip'd print files, PPD files, etc. * - * Copyright © 2021 by OpenPrinting. + * Copyright © 2021-2022 by OpenPrinting. * Copyright © 2007-2019 by Apple Inc. * Copyright © 1997-2007 by Easy Software Products, all rights reserved. * @@ -1100,8 +1100,7 @@ cupsFileOpen(const char *filename, /* I - Name of file */ switch (*mode) { case 'a' : /* Append file */ - fd = cups_open(filename, - O_RDWR | O_CREAT | O_APPEND | O_LARGEFILE | O_BINARY); + fd = cups_open(filename, O_WRONLY | O_CREAT | O_APPEND | O_LARGEFILE | O_BINARY); break; case 'r' : /* Read file */ @@ -1112,8 +1111,7 @@ cupsFileOpen(const char *filename, /* I - Name of file */ fd = cups_open(filename, O_WRONLY | O_LARGEFILE | O_BINARY); if (fd < 0 && errno == ENOENT) { - fd = cups_open(filename, - O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE | O_BINARY); + fd = cups_open(filename, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE | O_BINARY); if (fd < 0 && errno == EEXIST) fd = cups_open(filename, O_WRONLY | O_LARGEFILE | O_BINARY); } -- 2.47.2