Skip to content

Commit 2a32fe8

Browse files
committed
Fix some clang-detected issues:
- cups_open didn't always preserve the errno value. - ipp_file_t had an unused token_cb member. - cupsOAuthGetTokens didn't check for a NULL access_expires pointer. - ipptransform tried to continue running program after the pipe creation failed.
1 parent fcc7391 commit 2a32fe8

4 files changed

Lines changed: 17 additions & 10 deletions

File tree

cups/file.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ cupsFileOpen(const char *filename, // I - Name of file
656656
break;
657657

658658
case 'w' : // Write file
659-
fd = cups_open(filename, O_WRONLY | O_LARGEFILE | O_BINARY, perm);
659+
fd = cups_open(filename, O_WRONLY | O_LARGEFILE | O_BINARY, perm);
660660
if (fd < 0 && errno == ENOENT)
661661
{
662662
fd = cups_open(filename, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE | O_BINARY, perm);
@@ -1790,7 +1790,9 @@ cups_open(const char *filename, // I - Filename
17901790
// Then verify that the file descriptor doesn't point to a directory or hard-linked file.
17911791
if (fstat(fd, &fileinfo))
17921792
{
1793+
int temp = errno;
17931794
close(fd);
1795+
errno = temp;
17941796
return (-1);
17951797
}
17961798

@@ -1816,7 +1818,9 @@ cups_open(const char *filename, // I - Filename
18161818
// Then use lstat to determine whether the filename is a symlink...
18171819
if (lstat(filename, &linkinfo))
18181820
{
1821+
int temp = errno;
18191822
close(fd);
1823+
errno = temp;
18201824
return (-1);
18211825
}
18221826

cups/ipp-file.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// IPP data file functions.
33
//
4-
// Copyright © 2021-2024 by OpenPrinting.
4+
// Copyright © 2021-2025 by OpenPrinting.
55
// Copyright © 2007-2019 by Apple Inc.
66
// Copyright © 1997-2007 by Easy Software Products.
77
//
@@ -33,7 +33,6 @@ struct _ipp_file_s // IPP data file
3333
cups_option_t *vars; // Variables
3434
ipp_fattr_cb_t attr_cb; // Attribute (filter) callback
3535
ipp_ferror_cb_t error_cb; // Error reporting callback
36-
ipp_ftoken_cb_t token_cb; // Token processing callback
3736
void *cb_data; // Callback data
3837
char *buffer; // Output buffer
3938
size_t alloc_buffer; // Size of output buffer

cups/oauth.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,12 +1308,15 @@ cupsOAuthGetTokens(
13081308

13091309
if (error)
13101310
{
1311-
// Handle "soft" device access token errors by setting access_expires to
1312-
// the next call time...
1313-
if (!strcmp(error, "slow_down"))
1314-
*access_expires = time(NULL) + 10;
1315-
else
1316-
*access_expires = time(NULL) + 5;
1311+
if (access_expires)
1312+
{
1313+
// Handle "soft" device access token errors by setting access_expires to
1314+
// the next call time...
1315+
if (!strcmp(error, "slow_down"))
1316+
*access_expires = time(NULL) + 10;
1317+
else
1318+
*access_expires = time(NULL) + 5;
1319+
}
13171320

13181321
// Free memory and return...
13191322
cupsJSONDelete(response);

tools/ipptransform.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2763,14 +2763,15 @@ ps_convert_pdf(
27632763
if (pipe(stdout_pipe))
27642764
{
27652765
cupsLangPrintf(stderr, _("%s: Unable to create pipe for stdout: %s"), Prefix, strerror(errno));
2766-
stdout_pipe[0] = stdout_pipe[1] = -1;
2766+
return (1);
27672767
}
27682768

27692769
if ((pdftops_pid = fork()) == 0)
27702770
{
27712771
// Child comes here...
27722772
close(1);
27732773
dup2(stdout_pipe[1], 1);
2774+
27742775
close(stdout_pipe[0]);
27752776
close(stdout_pipe[1]);
27762777

0 commit comments

Comments
 (0)