Pull the final version of coverity fixes from upstream
This commit is contained in:
parent
9d3e012a91
commit
30a09c682d
@ -95,48 +95,100 @@ index 403dd60..4a2b67f 100644
|
||||
rc = -1;
|
||||
|
||||
if (! rc)
|
||||
commit 75568e8bea256657258f79d3f1a0736198d05b60
|
||||
Author: Jakub Jelen <jjelen@redhat.com>
|
||||
Date: Wed Apr 14 17:36:17 2021 +0200
|
||||
|
||||
tty: Avoid double fclose
|
||||
|
||||
* tty/pinentry-tty.c (tty_cmd_handler): Avoid double fclose
|
||||
|
||||
--
|
||||
|
||||
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
|
||||
From 7f7fd8bcfd74919091cc318b27b8617a9ef2ac82 Mon Sep 17 00:00:00 2001
|
||||
From: NIIBE Yutaka <gniibe@fsij.org>
|
||||
Date: Fri, 16 Apr 2021 12:54:43 +0900
|
||||
Subject: [PATCH] tty: Fix error return paths and its resource leaks.
|
||||
|
||||
* tty/pinentry-tty.c (tty_cmd_handler): Only call do_touch_file
|
||||
on successful interaction. Fix closing file.
|
||||
|
||||
--
|
||||
|
||||
GnuPG-bug-id: 5384
|
||||
Co-authored-by: Jakub Jelen <jjelen@redhat.com>
|
||||
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
|
||||
---
|
||||
tty/pinentry-tty.c | 34 +++++++++++++++++-----------------
|
||||
1 file changed, 17 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/tty/pinentry-tty.c b/tty/pinentry-tty.c
|
||||
index 4a2b67f..63e306f 100644
|
||||
index 4a2b67f..c4d85c6 100644
|
||||
--- a/tty/pinentry-tty.c
|
||||
+++ b/tty/pinentry-tty.c
|
||||
@@ -551,9 +551,6 @@ tty_cmd_handler (pinentry_t pinentry)
|
||||
ttyfo = fopen (pinentry->ttyname, "w");
|
||||
if (!ttyfo)
|
||||
{
|
||||
@@ -525,6 +525,7 @@ tty_cmd_handler (pinentry_t pinentry)
|
||||
int rc = 0;
|
||||
FILE *ttyfi = stdin;
|
||||
FILE *ttyfo = stdout;
|
||||
+ int saved_errno = 0;
|
||||
|
||||
#ifndef HAVE_DOSISH_SYSTEM
|
||||
timed_out = 0;
|
||||
@@ -545,30 +546,27 @@ tty_cmd_handler (pinentry_t pinentry)
|
||||
{
|
||||
ttyfi = fopen (pinentry->ttyname, "r");
|
||||
if (!ttyfi)
|
||||
- rc = -1;
|
||||
- else
|
||||
+ return -1;
|
||||
+
|
||||
+ ttyfo = fopen (pinentry->ttyname, "w");
|
||||
+ if (!ttyfo)
|
||||
{
|
||||
- ttyfo = fopen (pinentry->ttyname, "w");
|
||||
- if (!ttyfo)
|
||||
- {
|
||||
- int err = errno;
|
||||
- fclose (ttyfi);
|
||||
- errno = err;
|
||||
rc = -1;
|
||||
}
|
||||
- rc = -1;
|
||||
- }
|
||||
+ saved_errno = errno;
|
||||
+ fclose (ttyfi);
|
||||
+ errno = saved_errno;
|
||||
+ return -1;
|
||||
}
|
||||
@@ -562,7 +559,7 @@ tty_cmd_handler (pinentry_t pinentry)
|
||||
if (!rc && terminal_save (fileno (ttyfi)) < 0)
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
- if (!rc && terminal_save (fileno (ttyfi)) < 0)
|
||||
+ if (terminal_save (fileno (ttyfi)) < 0)
|
||||
rc = -1;
|
||||
-
|
||||
- if (! rc)
|
||||
+ if (!rc)
|
||||
+ else
|
||||
{
|
||||
if (terminal_setup (fileno (ttyfi), !!pinentry->pin) == -1)
|
||||
{
|
||||
@@ -583,7 +583,8 @@ tty_cmd_handler (pinentry_t pinentry)
|
||||
- int err = errno;
|
||||
+ saved_errno = errno;
|
||||
fprintf (stderr, "terminal_setup failure, exiting\n");
|
||||
- errno = err;
|
||||
+ rc = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -578,17 +576,19 @@ tty_cmd_handler (pinentry_t pinentry)
|
||||
rc = confirm (pinentry, ttyfi, ttyfo);
|
||||
|
||||
terminal_restore (fileno (ttyfi));
|
||||
+ do_touch_file (pinentry);
|
||||
}
|
||||
}
|
||||
|
||||
- do_touch_file (pinentry);
|
||||
-
|
||||
if (pinentry->ttyname)
|
||||
{
|
||||
fclose (ttyfi);
|
||||
- fclose (ttyfo);
|
||||
+ if (ttyfo)
|
||||
+ fclose (ttyfo);
|
||||
fclose (ttyfo);
|
||||
}
|
||||
|
||||
|
||||
+ if (saved_errno)
|
||||
+ errno = saved_errno;
|
||||
+
|
||||
return rc;
|
||||
}
|
||||
|
||||
--
|
||||
2.30.2
|
||||
|
Loading…
Reference in New Issue
Block a user