gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libextractor] 06/06: fix for NSF plugin's NPE reported by


From: gnunet
Subject: [GNUnet-SVN] [libextractor] 06/06: fix for NSF plugin's NPE reported by Leon Zhao
Date: Fri, 13 Oct 2017 12:37:46 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository libextractor.

commit 38e8933539ee9d044057b18a971c2eae3c21aba7
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Oct 13 12:36:36 2017 +0200

    fix for NSF plugin's NPE reported by Leon Zhao
---
 ChangeLog                   |  3 +++
 src/plugins/nsf_extractor.c | 32 +++++++++++++++++---------------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 73220830..78e5e3b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Fri Oct 13 12:30:37 CEST 2017
+       Properly check read error in NSF plugin (from signedness confusion) 
found by Leon Zhao. -CG
+
 Fri Oct 13 12:27:38 CEST 2017
        Protect against problematic integer offset in NSFE plugin found by Leon 
Zhao. -CG
 
diff --git a/src/plugins/nsf_extractor.c b/src/plugins/nsf_extractor.c
index c0945700..a02aaeeb 100644
--- a/src/plugins/nsf_extractor.c
+++ b/src/plugins/nsf_extractor.c
@@ -51,7 +51,7 @@ struct header
    * Magic code.
    */
   char magicid[5];
-  
+
   /**
    * NSF version number.
    */
@@ -86,9 +86,9 @@ struct header
    * Album title.
    */
   char title[32];
-  
+
   /**
-   * Artist name. 
+   * Artist name.
    */
   char artist[32];
 
@@ -152,13 +152,15 @@ EXTRACTOR_nsf_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
   char nsfversion[32];
   const struct header *head;
   void *data;
+  ssize_t ds;
 
-  if (sizeof (struct header) >
-      ec->read (ec->cls,
-               &data,
-               sizeof (struct header)))
+  ds = ec->read (ec->cls,
+                 &data,
+                 sizeof (struct header));
+  if ( (-1 == ds) ||
+       (sizeof (struct header) > ds) )
     return;
-  head = data; 
+  head = data;
 
   /* Check "magic" id bytes */
   if (memcmp (head->magicid, "NESM\x1a", 5))
@@ -166,17 +168,17 @@ EXTRACTOR_nsf_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
   ADD ("audio/x-nsf", EXTRACTOR_METATYPE_MIMETYPE);
   snprintf (nsfversion,
            sizeof(nsfversion),
-           "%d", 
+           "%d",
            head->nsfversion);
   ADD (nsfversion, EXTRACTOR_METATYPE_FORMAT_VERSION);
-  snprintf (songs, 
+  snprintf (songs,
            sizeof(songs),
            "%d",
            (int) head->songs);
   ADD (songs, EXTRACTOR_METATYPE_SONG_COUNT);
-  snprintf (startingsong, 
+  snprintf (startingsong,
            sizeof(startingsong),
-           "%d", 
+           "%d",
            (int) head->firstsong);
   ADD (startingsong, EXTRACTOR_METATYPE_STARTING_SONG);
   memcpy (&album, head->title, 32);
@@ -196,14 +198,14 @@ EXTRACTOR_nsf_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
   else
     {
       if (0 != (head->tvflags & PAL_FLAG))
-       ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);        
+       ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
       else
-        ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);        
+        ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
     }
 
   /* Detect Extra Sound Chips needed to play the files */
   if (0 != (head->chipflags & VRCVI_FLAG))
-    ADD ("VRCVI", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);    
+    ADD ("VRCVI", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
   if (0 != (head->chipflags & VRCVII_FLAG))
     ADD ("VRCVII", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
   if (0 != (head->chipflags & FDS_FLAG))

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]