Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-updates-src > by-pkgid > 1c086bd46aedd98d8942477e1373e659 > files > 4

gnutls-2.10.5-2.1.mga1.src.rpm

From f02d56a76e4ac5a6ebc65e5277250cbe73ba6ca0 Mon Sep 17 00:00:00 2001
From: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Date: Sat, 26 Mar 2011 01:01:17 +0100
Subject: [PATCH] Corrected access to freed memory location. Reported by Vitaly Kruglikov.

---
 lib/opencdk/stream.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/lib/opencdk/stream.c b/lib/opencdk/stream.c
index 4dfa8f1..0f3660f 100644
--- a/lib/opencdk/stream.c
+++ b/lib/opencdk/stream.c
@@ -761,6 +761,7 @@ stream_fp_replace (cdk_stream_t s, FILE ** tmp)
   rc = fclose (s->fp);
   if (rc)
     {
+      s->fp = NULL;
       gnutls_assert ();
       return CDK_File_Error;
     }
@@ -819,11 +820,12 @@ stream_filter_write (cdk_stream_t s)
       if (!rc)
 	rc = cdk_stream_seek (s, 0);
       if (rc)
-	{
-	  _cdk_log_debug ("filter [close]: fd=%d\n", fileno (f->tmp));
-	  fclose (f->tmp);
-	  break;
-	}
+        {
+          _gnutls_read_log ("filter [close]: fd=%d\n", fileno (f->tmp));
+          fclose (f->tmp);
+          f->tmp = NULL;
+          break;
+        }
     }
   return rc;
 }
@@ -958,13 +960,13 @@ cdk_stream_read (cdk_stream_t s, void *buf, size_t buflen)
     {
       rc = stream_filter_read (s);
       if (rc)
-	{
-	  s->error = rc;
-	  if (feof (s->fp))
-	    s->flags.eof = 1;
-	  gnutls_assert ();
-	  return EOF;
-	}
+        {
+          s->error = rc;
+          if (s->fp && feof (s->fp))
+            s->flags.eof = 1;
+          gnutls_assert ();
+          return EOF;
+        }
       s->flags.filtrated = 1;
     }
 
-- 
1.7.2.5