gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libextractor] branch master updated (d0a7ceb6 -> e340cef5)


From: gnunet
Subject: [GNUnet-SVN] [libextractor] branch master updated (d0a7ceb6 -> e340cef5)
Date: Sun, 15 Oct 2017 21:34:24 +0200

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

grothoff pushed a change to branch master
in repository libextractor.

    from d0a7ceb6 fix FD leak
     new a3f6574c indentation fixes
     new a666aaa2 fix potential assign-after-free
     new 4542314a avoid passing of char to isspace()-family of functions, 
always pass unsigned chars
     new 153ee0cc indentation fixes
     new f7135582 defensive programming: avoid malloc(0) in deb extractor
     new 0de56930 fix duration initialization in ffmpeg extractor (badly 
positioned #if)
     new b933ab4a doxygen improvements
     new 71aa4223 fix potential buffer underflow read in deb_extractor
     new a0268aec fix very hypothetical lack of 0-termination in ole2-extractor 
iff translation string was more than 10x as long as the English version
     new e0fba0ff be more careful with memory allocation failures in gsf 
extractor, avoid calling g_free(NULL)
     new bb818476 be more conservative about result from ctime_r
     new b2610cbb fix NPE in extract for 0-byte values
     new 784e6fff seems some specs of c_time allow up to 71 bytes, so increase 
buffer size just to be safe
     new 58626426 add missing continue if max meta data was reached to avoid 
use after free
     new 73e1679e fix indentation
     new 85daaa32 handle allocation failure in gstreamer plugin
     new 774014cd handle allocation failure in PDF fdopen call
     new f675653e do not try to seek on SHM if we do not use SHM, even if (bad) 
plugin requests it
     new f792c47a need isspace, not isblank for rpm extractor
     new d9d073c6 fix signed/unsigned comparison issue
     new 4eec0dd2 handle IPC_shared_memory_set_ error
     new ae35ecce remove useless assignment
     new e7ce6d72 extra-carefully check return value of snprintf
     new 3d4576cf avoid calling free(NULL) on plugin load error
     new e3e54b4f avoid NPE on empty value in grep-friendly printing
     new 8968dccf check return values from dup2()
     new e340cef5 update gitignore

The 27 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                              |   4 +
 ChangeLog                               |   8 +-
 src/common/unzip.c                      | 328 +++++++++++++-------------
 src/main/extract.c                      |  98 ++++----
 src/main/extractor.c                    |  19 +-
 src/main/extractor_datasource.c         |   5 +-
 src/main/extractor_ipc_gnu.c            |  27 ++-
 src/main/extractor_plugins.c            |  40 ++--
 src/main/extractor_plugpath.c           |   5 +-
 src/plugins/deb_extractor.c             |  32 +--
 src/plugins/gstreamer_extractor.c       | 398 ++++++++++++++++++++++----------
 src/plugins/jpeg_extractor.c            |   2 +-
 src/plugins/ogg_extractor.c             |   8 +-
 src/plugins/ole2_extractor.c            | 110 +++++----
 src/plugins/pdf_extractor.c             |  16 +-
 src/plugins/ps_extractor.c              |  16 +-
 src/plugins/rpm_extractor.c             |   9 +-
 src/plugins/thumbnailffmpeg_extractor.c |  28 +--
 18 files changed, 684 insertions(+), 469 deletions(-)

diff --git a/.gitignore b/.gitignore
index a5882a23..9f1333b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,6 +54,7 @@ po/pl.gmo
 po/ro.gmo
 po/rw.gmo
 po/stamp-po
+po/sr.gmo
 po/sv.gmo
 po/uk.gmo
 po/vi.gmo
@@ -161,6 +162,8 @@ src/plugins/it_extractor.lo
 src/plugins/it_extractor.o
 src/plugins/jpeg_extractor.lo
 src/plugins/jpeg_extractor.o
+src/plugins/thumbnailffmpeg_extractor.lo
+src/plugins/thumbnailffmpeg_extractor.o
 src/plugins/libextractor_archive.la
 src/plugins/libextractor_deb.la
 src/plugins/libextractor_dvi.la
@@ -168,6 +171,7 @@ src/plugins/libextractor_exiv2.la
 src/plugins/libextractor_flac.la
 src/plugins/libextractor_gif.la
 src/plugins/libextractor_gstreamer.la
+src/plugins/libextractor_thumbnailffmpeg.la
 src/plugins/libextractor_gstreamer_la-gstreamer_extractor.lo
 src/plugins/libextractor_gstreamer_la-gstreamer_extractor.o
 src/plugins/libextractor_html.la
diff --git a/ChangeLog b/ChangeLog
index 0b9e9cef..65ef35a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 Sun Oct 15 19:36:41 CEST 2017
-       Fix potential file descriptor leak (on error handling path). -CG
+       Fix potential file descriptor leak (on error handling path).
+       Fix potential assign-after-free (on IPC error handling path).
+       Make sure to only pass "unsigned char" to functions like isspace().
+       Avoid malloc(0) in DEB extractor under certain conditions.
+       Properly initialize 'duration' in ffmpeg extractor.
+       Fix potential buffer underflow read in DEB extractor.
+       Avoid NPE in 'extract' if extracted value has 0 bytes. -CG
 
 Fri Oct 13 12:30:37 CEST 2017
        Properly check read error in NSF plugin (from signedness confusion) 
found by Leon Zhao. -CG
diff --git a/src/common/unzip.c b/src/common/unzip.c
index 749d783a..0de77784 100644
--- a/src/common/unzip.c
+++ b/src/common/unzip.c
@@ -21,7 +21,7 @@
  * @file common/unzip.c
  * @brief API to access ZIP archives
  * @author Christian Grothoff
- * 
+ *
  * This code is based in part on
  * unzip 1.00 Copyright 1998-2003 Gilles Vollant
  * http://www.winimage.com/zLibDll";
@@ -39,7 +39,7 @@
  *
  * This assumes that the zip file is considered to be 
non-corrupt/non-truncated.
  * If it is truncated then it's not considered to be a zip and skipped.
- *  
+ *
  * ZIP format description from appnote.iz and appnote.txt (more or less):
  *
  *   (this is why you always need to put in the last floppy if you span disks)
@@ -137,21 +137,21 @@ struct FileFuncDefs
 
 /**
  * Global data about the ZIPfile
- * These data comes from the end of central dir 
+ * These data comes from the end of central dir
  */
 struct GlobalInfo
 {
 
   /**
    * total number of entries in
-   * the central dir on this disk 
+   * the central dir on this disk
    */
-  uLong number_entry;        
-  
+  uLong number_entry;
+
   /**
-   * size of the global comment of the zipfile 
+   * size of the global comment of the zipfile
    */
-  uLong size_comment;         
+  uLong size_comment;
 
   /**
    * offset of the global comment in the zipfile
@@ -167,7 +167,7 @@ struct UnzipFileInfoInternal
 {
 
   /**
-   * relative offset of local header 4 bytes 
+   * relative offset of local header 4 bytes
    */
   uLong offset_curfile;
 
@@ -181,69 +181,69 @@ struct UnzipFileInfoInternal
 struct FileInZipReadInfo
 {
   /**
-   * internal buffer for compressed data 
+   * internal buffer for compressed data
    */
-  char *read_buffer;         
+  char *read_buffer;
 
   /**
-   * zLib stream structure for inflate 
+   * zLib stream structure for inflate
    */
-  z_stream stream;            
-  
+  z_stream stream;
+
   /**
    * position in byte on the zipfile, for fseek
    */
-  uLong pos_in_zipfile;       
+  uLong pos_in_zipfile;
 
   /**
    * flag set if stream structure is initialised
    */
-  uLong stream_initialised;   
-  
+  uLong stream_initialised;
+
   /**
-   * offset of the local extra field 
+   * offset of the local extra field
    */
   uLong offset_local_extrafield;
 
   /**
-   * size of the local extra field 
+   * size of the local extra field
    */
   uInt  size_local_extrafield;
 
   /**
    * position in the local extra field in read
    */
-  uLong pos_local_extrafield;   
-  
+  uLong pos_local_extrafield;
+
   /**
    * crc32 of all data uncompressed so far
    */
-  uLong crc32;                
+  uLong crc32;
 
   /**
-   * crc32 we must obtain after decompress all 
+   * crc32 we must obtain after decompress all
    */
-  uLong crc32_wait;           
+  uLong crc32_wait;
 
   /**
-   * number of bytes to be decompressed 
+   * number of bytes to be decompressed
    */
-  uLong rest_read_compressed; 
-  
+  uLong rest_read_compressed;
+
   /**
    * number of bytes to be obtained after decomp
    */
   uLong rest_read_uncompressed;
-  
+
   /**
    * IO functions.
-   */ 
+   */
   struct FileFuncDefs z_filefunc;
 
   /**
-   * compression method (0==store) 
+   * compression method (0==store)
    */
-  uLong compression_method;   
+  uLong compression_method;
 
   /**
    * byte before the zipfile, (>0 for sfx)
@@ -259,65 +259,65 @@ struct FileInZipReadInfo
 struct EXTRACTOR_UnzipFile
 {
   /**
-   * io structore of the zipfile 
+   * io structore of the zipfile
    */
   struct FileFuncDefs z_filefunc;
 
   /**
-   * public global information 
+   * public global information
    */
-  struct GlobalInfo gi;       
-  
+  struct GlobalInfo gi;
+
   /**
    * byte before the zipfile, (>0 for sfx)
    */
   uLong byte_before_the_zipfile;
-  
+
   /**
    * number of the current file in the zipfile
    */
-  uLong num_file;             
+  uLong num_file;
 
   /**
    * pos of the current file in the central dir
    */
-  uLong pos_in_central_dir;   
-  
+  uLong pos_in_central_dir;
+
   /**
    * flag about the usability of the current file
    */
-  uLong current_file_ok;      
+  uLong current_file_ok;
 
   /**
    * position of the beginning of the central dir
    */
-  uLong central_pos;          
-  
+  uLong central_pos;
+
   /**
-   * size of the central directory  
+   * size of the central directory
    */
-  uLong size_central_dir;    
+  uLong size_central_dir;
 
   /**
    * offset of start of central directory with respect to the starting
    * disk number
-   */ 
-  uLong offset_central_dir;  
+   */
+  uLong offset_central_dir;
 
   /**
    * public info about the current file in zip
    */
   struct EXTRACTOR_UnzipFileInfo cur_file_info;
-  
+
   /**
    * private info about it
-   */ 
-  struct UnzipFileInfoInternal cur_file_info_internal; 
+   */
+  struct UnzipFileInfoInternal cur_file_info_internal;
 
   /**
    * structure about the current file if we are decompressing it
    */
-  struct FileInZipReadInfo *pfile_in_zip_read; 
+  struct FileInZipReadInfo *pfile_in_zip_read;
 
   /**
    * Is the file encrypted?
@@ -333,9 +333,9 @@ struct EXTRACTOR_UnzipFile
  *
  * @param ffd functions for performing IO operations
  * @param pi where to store the byte that was read
- * @return EXTRACTOR_UNZIP_OK on success, or EXTRACTOR_UNZIP_EOF
+ * @return #EXTRACTOR_UNZIP_OK on success, or #EXTRACTOR_UNZIP_EOF
  */
-static int 
+static int
 read_byte_from_ffd (const struct FileFuncDefs *ffd,
                    int *pi)
 {
@@ -355,23 +355,23 @@ read_byte_from_ffd (const struct FileFuncDefs *ffd,
  *
  * @param ffd functions for performing IO operations
  * @param pi where to store the short that was read
- * @return EXTRACTOR_UNZIP_OK on success, or EXTRACTOR_UNZIP_EOF
+ * @return #EXTRACTOR_UNZIP_OK on success, or #EXTRACTOR_UNZIP_EOF
  */
-static int 
+static int
 read_short_from_ffd (const struct FileFuncDefs *ffd,
                     uLong *pX)
 {
   uLong x;
   int i;
   int err;
-  
+
   *pX = 0;
   if (EXTRACTOR_UNZIP_OK != (err = read_byte_from_ffd (ffd, &i)))
     return err;
   x = (uLong) i;
   if (EXTRACTOR_UNZIP_OK != (err = read_byte_from_ffd (ffd, &i)))
     return err;
-  x += ((uLong) i) << 8;  
+  x += ((uLong) i) << 8;
   *pX = x;
   return err;
 }
@@ -384,16 +384,16 @@ read_short_from_ffd (const struct FileFuncDefs *ffd,
  *
  * @param ffd functions for performing IO operations
  * @param pi where to store the long that was read
- * @return EXTRACTOR_UNZIP_OK on success, or EXTRACTOR_UNZIP_EOF
+ * @return #EXTRACTOR_UNZIP_OK on success, or #EXTRACTOR_UNZIP_EOF
  */
-static int 
+static int
 read_long_from_ffd (const struct FileFuncDefs *ffd,
                    uLong *pX)
 {
   uLong x;
   int i;
   int err;
-  
+
   *pX = 0;
   if (EXTRACTOR_UNZIP_OK != (err = read_byte_from_ffd (ffd, &i)))
     return err;
@@ -435,7 +435,7 @@ read_long_from_ffd (const struct FileFuncDefs *ffd,
  *        0 for defaut of your operating system (like 1 on Unix, 2 on Windows)
  * @return 0 if names are equal
  */
-static int 
+static int
 EXTRACTOR_common_unzip_string_file_name_compare (const char* fileName1,
                                                 const char* fileName2,
                                                 int iCaseSensitivity)
@@ -459,14 +459,14 @@ EXTRACTOR_common_unzip_string_file_name_compare (const 
char* fileName1,
  * @param ffd IO functions
  * @return offset of central directory, 0 on error
  */
-static uLong 
+static uLong
 locate_central_directory (const struct FileFuncDefs *ffd)
 {
   unsigned char buf[BUFREADCOMMENT + 4];
   uLong uSizeFile;
   uLong uBackRead;
   uLong uMaxBack = 0xffff; /* maximum size of global comment */
-  
+
   if (0 != ZSEEK (*ffd, 0, SEEK_END))
     return 0;
   uSizeFile = ZTELL (*ffd);
@@ -484,18 +484,18 @@ locate_central_directory (const struct FileFuncDefs *ffd)
       else
        uBackRead += BUFREADCOMMENT;
       uReadPos = uSizeFile - uBackRead;
-      uReadSize = ((BUFREADCOMMENT + 4) < (uSizeFile - uReadPos)) 
-       ? (BUFREADCOMMENT + 4) 
+      uReadSize = ((BUFREADCOMMENT + 4) < (uSizeFile - uReadPos))
+       ? (BUFREADCOMMENT + 4)
        : (uSizeFile - uReadPos);
       if (0 != ZSEEK (*ffd, uReadPos, SEEK_SET))
        break;
       if (ZREAD (*ffd, buf, uReadSize) != uReadSize)
        break;
-      i = (int) uReadSize - 3; 
+      i = (int) uReadSize - 3;
       while (i-- > 0)
        if ( (0x50 == (*(buf+i))) &&
             (0x4b == (*(buf+i+1))) &&
-            (0x05 == (*(buf+i+2))) && 
+            (0x05 == (*(buf+i+2))) &&
             (0x06 == (*(buf+i+3))) )
          return uReadPos + i;
     }
@@ -504,13 +504,13 @@ locate_central_directory (const struct FileFuncDefs *ffd)
 
 
 /**
- * Translate date/time from Dos format to struct
- * EXTRACTOR_UnzipDateTimeInfo (readable more easilty)
+ * Translate date/time from Dos format to `struct
+ * EXTRACTOR_UnzipDateTimeInfo` (readable more easilty)
  *
  * @param ulDosDate time in DOS format (input)
  * @param ptm where to write time in readable format
  */
-static void 
+static void
 dos_date_to_tmu_date (uLong ulDosDate,
                           struct EXTRACTOR_UnzipDateTimeInfo* ptm)
 {
@@ -536,12 +536,12 @@ dos_date_to_tmu_date (uLong ulDosDate,
  * @param szFileName where to write the name of the current file
  * @param fileNameBufferSize number of bytes available in szFileName
  * @param extraField where to write extra data
- * @param extraFieldBufferSize number of bytes available in extraField 
+ * @param extraFieldBufferSize number of bytes available in extraField
  * @param szComment where to write the comment on the current file
  * @param commentBufferSize number of bytes available in szComment
- * @return EXTRACTOR_UNZIP_OK if there is no problem.
+ * @return #EXTRACTOR_UNZIP_OK if there is no problem.
  */
-static int 
+static int
 get_current_file_info (struct EXTRACTOR_UnzipFile *file,
                       struct EXTRACTOR_UnzipFileInfo *pfile_info,
                       struct UnzipFileInfoInternal *pfile_info_internal,
@@ -556,7 +556,7 @@ get_current_file_info (struct EXTRACTOR_UnzipFile *file,
   struct UnzipFileInfoInternal file_info_internal;
   uLong uMagic;
   long lSeek = 0;
-    
+
   if (NULL == file)
     return EXTRACTOR_UNZIP_PARAMERROR;
   if (0 != ZSEEK (file->z_filefunc,
@@ -619,14 +619,14 @@ get_current_file_info (struct EXTRACTOR_UnzipFile *file,
         }
       else
        uSizeRead = fileNameBufferSize;
-      
-      if ( (file_info.size_filename > 0) && 
+
+      if ( (file_info.size_filename > 0) &&
           (fileNameBufferSize > 0) )
        if (ZREAD(file->z_filefunc, szFileName, uSizeRead) != uSizeRead)
          return EXTRACTOR_UNZIP_ERRNO;
       lSeek -= uSizeRead;
     }
-  
+
   if (NULL != extraField)
     {
       uLong uSizeRead;
@@ -635,8 +635,8 @@ get_current_file_info (struct EXTRACTOR_UnzipFile *file,
        uSizeRead = file_info.size_file_extra;
       else
        uSizeRead = extraFieldBufferSize;
-      
-      if (0 != lSeek) 
+
+      if (0 != lSeek)
        {
          if (0 == ZSEEK (file->z_filefunc, lSeek, SEEK_CUR))
            lSeek = 0;
@@ -644,8 +644,8 @@ get_current_file_info (struct EXTRACTOR_UnzipFile *file,
            return EXTRACTOR_UNZIP_ERRNO;
        }
       if ( (file_info.size_file_extra > 0) &&
-          (extraFieldBufferSize > 0) && 
-          (ZREAD (file->z_filefunc, 
+          (extraFieldBufferSize > 0) &&
+          (ZREAD (file->z_filefunc,
                   extraField,
                   uSizeRead) != uSizeRead) )
        return EXTRACTOR_UNZIP_ERRNO;
@@ -653,7 +653,7 @@ get_current_file_info (struct EXTRACTOR_UnzipFile *file,
     }
   else
     lSeek += file_info.size_file_extra;
-  
+
   if (NULL != szComment)
     {
       uLong uSizeRead;
@@ -665,8 +665,8 @@ get_current_file_info (struct EXTRACTOR_UnzipFile *file,
         }
       else
        uSizeRead = commentBufferSize;
-      
-      if (0 != lSeek) 
+
+      if (0 != lSeek)
        {
          if (0 == ZSEEK (file->z_filefunc, lSeek, SEEK_CUR))
            lSeek = 0;
@@ -681,7 +681,7 @@ get_current_file_info (struct EXTRACTOR_UnzipFile *file,
     }
   else
     lSeek += file_info.size_file_comment;
-  
+
   if (NULL != pfile_info)
     *pfile_info = file_info;
   if (NULL != pfile_info_internal)
@@ -696,7 +696,7 @@ get_current_file_info (struct EXTRACTOR_UnzipFile *file,
  * @param file zipfile to manipulate
  * @return UNZ_OK if there is no problem
  */
-int 
+int
 EXTRACTOR_common_unzip_go_to_first_file (struct EXTRACTOR_UnzipFile *file)
 {
   int err;
@@ -720,7 +720,7 @@ EXTRACTOR_common_unzip_go_to_first_file (struct 
EXTRACTOR_UnzipFile *file)
  * @param ffd IO functions
  * @return NULL on error
  */
-static struct EXTRACTOR_UnzipFile * 
+static struct EXTRACTOR_UnzipFile *
 unzip_open_using_ffd (struct FileFuncDefs *ffd)
 {
   struct EXTRACTOR_UnzipFile us;
@@ -735,56 +735,56 @@ unzip_open_using_ffd (struct FileFuncDefs *ffd)
                                 the central dir
                                 (same than number_entry on nospan) */
 
-  memset (&us, 0, sizeof(us)); 
+  memset (&us, 0, sizeof(us));
   us.z_filefunc = *ffd;
   central_pos = locate_central_directory (&us.z_filefunc);
   if (0 == central_pos)
     return NULL;
-  if (0 != ZSEEK (us.z_filefunc, 
+  if (0 != ZSEEK (us.z_filefunc,
                  central_pos, SEEK_SET))
     return NULL;
-  
+
   /* the signature, already checked */
-  if (EXTRACTOR_UNZIP_OK != 
+  if (EXTRACTOR_UNZIP_OK !=
       read_long_from_ffd (&us.z_filefunc, &uL))
     return NULL;
-  
+
   /* number of this disk */
   if (EXTRACTOR_UNZIP_OK !=
       read_short_from_ffd (&us.z_filefunc, &number_disk))
     return NULL;
-  
+
   /* number of the disk with the start of the central directory */
   if (EXTRACTOR_UNZIP_OK !=
       read_short_from_ffd (&us.z_filefunc, &number_disk_with_CD))
     return NULL;
-  
+
   /* total number of entries in the central dir on this disk */
   if (EXTRACTOR_UNZIP_OK !=
       read_short_from_ffd (&us.z_filefunc, &us.gi.number_entry))
     return NULL;
-  
+
   /* total number of entries in the central dir */
   if (EXTRACTOR_UNZIP_OK !=
       read_short_from_ffd (&us.z_filefunc, &number_entry_CD))
     return NULL;
-  
+
   if ( (number_entry_CD != us.gi.number_entry) ||
        (0 != number_disk_with_CD) ||
        (0 != number_disk) )
     return NULL;
-  
+
   /* size of the central directory */
   if (EXTRACTOR_UNZIP_OK !=
       read_long_from_ffd (&us.z_filefunc, &us.size_central_dir))
     return NULL;
-  
+
   /* offset of start of central directory with respect to the
      starting disk number */
   if (EXTRACTOR_UNZIP_OK !=
       read_long_from_ffd (&us.z_filefunc, &us.offset_central_dir))
     return NULL;
-  
+
   /* zipfile comment length */
   if (EXTRACTOR_UNZIP_OK !=
       read_short_from_ffd (&us.z_filefunc, &us.gi.size_comment))
@@ -792,13 +792,13 @@ unzip_open_using_ffd (struct FileFuncDefs *ffd)
   us.gi.offset_comment = ZTELL (us.z_filefunc);
   if ((central_pos < us.offset_central_dir + us.size_central_dir))
     return NULL;
-  
+
   us.byte_before_the_zipfile = central_pos -
     (us.offset_central_dir + us.size_central_dir);
   us.central_pos = central_pos;
   us.pfile_in_zip_read = NULL;
   us.encrypted = 0;
-  
+
   if (NULL == (file = malloc (sizeof(struct EXTRACTOR_UnzipFile))))
     return NULL;
   *file = us;
@@ -808,16 +808,16 @@ unzip_open_using_ffd (struct FileFuncDefs *ffd)
 
 
 /**
- * Close the file in zip opened with EXTRACTOR_common_unzip_open_current_file.
+ * Close the file in zip opened with 
#EXTRACTOR_common_unzip_open_current_file().
  *
- * @return EXTRACTOR_UNZIP_CRCERROR if all the file was read but the CRC is 
not good
+ * @return #EXTRACTOR_UNZIP_CRCERROR if all the file was read but the CRC is 
not good
  */
-int 
+int
 EXTRACTOR_common_unzip_close_current_file (struct EXTRACTOR_UnzipFile *file)
 {
   struct FileInZipReadInfo* pfile_in_zip_read_info;
   int err = EXTRACTOR_UNZIP_OK;
-  
+
   if (NULL == file)
     return EXTRACTOR_UNZIP_PARAMERROR;
   if (NULL == (pfile_in_zip_read_info = file->pfile_in_zip_read))
@@ -841,9 +841,9 @@ EXTRACTOR_common_unzip_close_current_file (struct 
EXTRACTOR_UnzipFile *file)
  * Close a ZipFile.
  *
  * @param file zip file to close
- * @return EXTRACTOR_UNZIP_OK if there is no problem. 
+ * @return #EXTRACTOR_UNZIP_OK if there is no problem.
  */
-int 
+int
 EXTRACTOR_common_unzip_close (struct EXTRACTOR_UnzipFile *file)
 {
   if (NULL == file)
@@ -861,7 +861,7 @@ EXTRACTOR_common_unzip_close (struct EXTRACTOR_UnzipFile 
*file)
  * @param file unzip file to inspect
  * @param comment where to copy the comment
  * @param comment_len maximum number of bytes available in comment
- * @return EXTRACTOR_UNZIP_OK on success
+ * @return #EXTRACTOR_UNZIP_OK on success
  */
 int
 EXTRACTOR_common_unzip_get_global_comment (struct EXTRACTOR_UnzipFile *file,
@@ -892,10 +892,10 @@ EXTRACTOR_common_unzip_get_global_comment (struct 
EXTRACTOR_UnzipFile *file,
  * @param szFileName where to write the name of the current file
  * @param fileNameBufferSize number of bytes available in szFileName
  * @param extraField where to write extra data
- * @param extraFieldBufferSize number of bytes available in extraField 
+ * @param extraFieldBufferSize number of bytes available in extraField
  * @param szComment where to write the comment on the current file
  * @param commentBufferSize number of bytes available in szComment
- * @return EXTRACTOR_UNZIP_OK if there is no problem.
+ * @return #EXTRACTOR_UNZIP_OK if there is no problem.
  */
 int
 EXTRACTOR_common_unzip_get_current_file_info (struct EXTRACTOR_UnzipFile * 
file,
@@ -918,14 +918,14 @@ EXTRACTOR_common_unzip_get_current_file_info (struct 
EXTRACTOR_UnzipFile * file,
  * Set the current file of the zipfile to the next file.
  *
  * @param file zipfile to manipulate
- * @return EXTRACTOR_UNZIP_OK if there is no problem,
- *         EXTRACTOR_UNZIP_END_OF_LIST_OF_FILE if the actual file was the 
latest.
+ * @return #EXTRACTOR_UNZIP_OK if there is no problem,
+ *         #EXTRACTOR_UNZIP_END_OF_LIST_OF_FILE if the actual file was the 
latest.
  */
-int 
+int
 EXTRACTOR_common_unzip_go_to_next_file (struct EXTRACTOR_UnzipFile *file)
 {
   int err;
-  
+
   if (NULL == file)
     return EXTRACTOR_UNZIP_PARAMERROR;
   if (! file->current_file_ok)
@@ -935,7 +935,7 @@ EXTRACTOR_common_unzip_go_to_next_file (struct 
EXTRACTOR_UnzipFile *file)
   file->pos_in_central_dir += SIZECENTRALDIRITEM + 
file->cur_file_info.size_filename +
     file->cur_file_info.size_file_extra + 
file->cur_file_info.size_file_comment;
   file->num_file++;
-  err = get_current_file_info (file, 
+  err = get_current_file_info (file,
                               &file->cur_file_info,
                               &file->cur_file_info_internal,
                               NULL, 0, NULL, 0, NULL, 0);
@@ -946,17 +946,17 @@ EXTRACTOR_common_unzip_go_to_next_file (struct 
EXTRACTOR_UnzipFile *file)
 
 /**
  * Try locate the file szFileName in the zipfile.
- * 
+ *
  * @param file zipfile to manipulate
  * @param szFileName name to find
  * @param iCaseSensitivity, use 1 for case sensitivity (like strcmp);
  *        2 for no case sensitivity (like strcmpi or strcasecmp); or
  *        0 for defaut of your operating system (like 1 on Unix, 2 on Windows)
- * @return EXTRACTOR_UNZIP_OK if the file is found. It becomes the current 
file.
- *         EXTRACTOR_UNZIP_END_OF_LIST_OF_FILE if the file is not found
+ * @return #EXTRACTOR_UNZIP_OK if the file is found. It becomes the current 
file.
+ *         #EXTRACTOR_UNZIP_END_OF_LIST_OF_FILE if the file is not found
  */
 int
-EXTRACTOR_common_unzip_go_find_local_file (struct EXTRACTOR_UnzipFile *file, 
+EXTRACTOR_common_unzip_go_find_local_file (struct EXTRACTOR_UnzipFile *file,
                                           const char *szFileName,
                                           int iCaseSensitivity)
 {
@@ -968,28 +968,28 @@ EXTRACTOR_common_unzip_go_find_local_file (struct 
EXTRACTOR_UnzipFile *file,
   struct UnzipFileInfoInternal cur_file_info_internalSaved;
   uLong num_fileSaved;
   uLong pos_in_central_dirSaved;
-    
+
   if (NULL == file)
     return EXTRACTOR_UNZIP_PARAMERROR;
   if (strlen (szFileName) >= UNZ_MAXFILENAMEINZIP)
     return EXTRACTOR_UNZIP_PARAMERROR;
   if (! file->current_file_ok)
     return EXTRACTOR_UNZIP_END_OF_LIST_OF_FILE;
-  
+
   /* Save the current state */
   num_fileSaved = file->num_file;
   pos_in_central_dirSaved = file->pos_in_central_dir;
   cur_file_infoSaved = file->cur_file_info;
   cur_file_info_internalSaved = file->cur_file_info_internal;
   err = EXTRACTOR_common_unzip_go_to_first_file (file);
-  
+
   while (EXTRACTOR_UNZIP_OK == err)
     {
       char szCurrentFileName[UNZ_MAXFILENAMEINZIP + 1];
 
       if (EXTRACTOR_UNZIP_OK !=
          (err = EXTRACTOR_common_unzip_get_current_file_info (file, NULL,
-                                                              
szCurrentFileName, 
+                                                              
szCurrentFileName,
                                                               sizeof 
(szCurrentFileName) - 1,
                                                               NULL, 0, NULL, 
0)))
        break;
@@ -1000,7 +1000,7 @@ EXTRACTOR_common_unzip_go_find_local_file (struct 
EXTRACTOR_UnzipFile *file,
        return EXTRACTOR_UNZIP_OK;
       err = EXTRACTOR_common_unzip_go_to_next_file (file);
     }
-  
+
   /* We failed, so restore the state of the 'current file' to where we
    * were.
    */
@@ -1020,9 +1020,9 @@ EXTRACTOR_common_unzip_go_find_local_file (struct 
EXTRACTOR_UnzipFile *file,
  * @return the number of byte copied if somes bytes are copied
  *         0 if the end of file was reached
  *         <0 with error code if there is an error
- *        (EXTRACTOR_UNZIP_ERRNO for IO error, or zLib error for uncompress 
error)
+ *        (#EXTRACTOR_UNZIP_ERRNO for IO error, or zLib error for uncompress 
error)
  */
-ssize_t 
+ssize_t
 EXTRACTOR_common_unzip_read_current_file (struct EXTRACTOR_UnzipFile *file,
                                          void *buf,
                                          size_t len)
@@ -1045,7 +1045,7 @@ EXTRACTOR_common_unzip_read_current_file (struct 
EXTRACTOR_UnzipFile *file,
   if (len > pfile_in_zip_read_info->rest_read_uncompressed)
     pfile_in_zip_read_info->stream.avail_out =
       (uInt) pfile_in_zip_read_info->rest_read_uncompressed;
-  
+
   while (pfile_in_zip_read_info->stream.avail_out > 0)
     {
       if ( (0 == pfile_in_zip_read_info->stream.avail_in) &&
@@ -1056,7 +1056,7 @@ EXTRACTOR_common_unzip_read_current_file (struct 
EXTRACTOR_UnzipFile *file,
            uReadThis = (uInt) pfile_in_zip_read_info->rest_read_compressed;
          if (0 == uReadThis)
            return EXTRACTOR_UNZIP_EOF;
-         if (0 != 
+         if (0 !=
              ZSEEK (pfile_in_zip_read_info->z_filefunc,
                     pfile_in_zip_read_info->pos_in_zipfile +
                     pfile_in_zip_read_info->byte_before_the_zipfile,
@@ -1066,22 +1066,22 @@ EXTRACTOR_common_unzip_read_current_file (struct 
EXTRACTOR_UnzipFile *file,
                     pfile_in_zip_read_info->read_buffer,
                     uReadThis) != uReadThis)
            return EXTRACTOR_UNZIP_ERRNO;
-         
-         pfile_in_zip_read_info->pos_in_zipfile += uReadThis;    
+
+         pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
          pfile_in_zip_read_info->rest_read_compressed -= uReadThis;
          pfile_in_zip_read_info->stream.next_in =
            (Bytef *) pfile_in_zip_read_info->read_buffer;
          pfile_in_zip_read_info->stream.avail_in = (uInt) uReadThis;
         }
-      
+
       if (0 == pfile_in_zip_read_info->compression_method)
        {
          uInt uDoCopy;
-         
+
          if ( (0 == pfile_in_zip_read_info->stream.avail_in) &&
               (0 == pfile_in_zip_read_info->rest_read_compressed) )
            return (0 == iRead) ? EXTRACTOR_UNZIP_EOF : iRead;
-         
+
          if (pfile_in_zip_read_info->stream.avail_out <
              pfile_in_zip_read_info->stream.avail_in)
            uDoCopy = pfile_in_zip_read_info->stream.avail_out;
@@ -1108,10 +1108,10 @@ EXTRACTOR_common_unzip_read_current_file (struct 
EXTRACTOR_UnzipFile *file,
          const Bytef *bufBefore;
          uLong uOutThis;
          int flush = Z_SYNC_FLUSH;
-         
+
          uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
          bufBefore = pfile_in_zip_read_info->stream.next_out;
-         
+
          /*
            if ((pfile_in_zip_read_info->rest_read_uncompressed ==
            pfile_in_zip_read_info->stream.avail_out) &&
@@ -1119,26 +1119,26 @@ EXTRACTOR_common_unzip_read_current_file (struct 
EXTRACTOR_UnzipFile *file,
            flush = Z_FINISH;
          */
          err = inflate (&pfile_in_zip_read_info->stream, flush);
-         
+
          uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
          uOutThis = uTotalOutAfter-uTotalOutBefore;
-         
+
          pfile_in_zip_read_info->crc32 =
            crc32 (pfile_in_zip_read_info->crc32, bufBefore,
                   (uInt) (uOutThis));
-         
+
          pfile_in_zip_read_info->rest_read_uncompressed -=
            uOutThis;
-         
+
          iRead += (uInt) (uTotalOutAfter - uTotalOutBefore);
-         
+
          if (Z_STREAM_END == err)
            return (0 == iRead) ? EXTRACTOR_UNZIP_EOF : iRead;
          if (Z_OK != err)
            break;
        }
     }
-  
+
   if (Z_OK == err)
     return iRead;
   return err;
@@ -1155,9 +1155,9 @@ EXTRACTOR_common_unzip_read_current_file (struct 
EXTRACTOR_UnzipFile *file,
  * @param piSizeVar where to store the size of the extra info
  * @param poffset_local_extrafield where to store the offset of the local 
extrafield
  * @param psoze_local_extrafield where to store the size of the local 
extrafield
- * @return EXTRACTOR_UNZIP_OK on success
+ * @return #EXTRACTOR_UNZIP_OK on success
  */
-static int 
+static int
 parse_current_file_coherency_header (struct EXTRACTOR_UnzipFile *file,
                                     uInt *piSizeVar,
                                     uLong *poffset_local_extrafield,
@@ -1172,10 +1172,10 @@ parse_current_file_coherency_header (struct 
EXTRACTOR_UnzipFile *file,
   *piSizeVar = 0;
   *poffset_local_extrafield = 0;
   *psize_local_extrafield = 0;
-  
-  if (0 != ZSEEK (file->z_filefunc, 
+
+  if (0 != ZSEEK (file->z_filefunc,
                  file->cur_file_info_internal.offset_curfile +
-                 file->byte_before_the_zipfile, 
+                 file->byte_before_the_zipfile,
                  SEEK_SET))
     return EXTRACTOR_UNZIP_ERRNO;
   if (EXTRACTOR_UNZIP_OK !=
@@ -1183,7 +1183,7 @@ parse_current_file_coherency_header (struct 
EXTRACTOR_UnzipFile *file,
                          &uMagic))
     return EXTRACTOR_UNZIP_ERRNO;
   if (0x04034b50 != uMagic)
-    return EXTRACTOR_UNZIP_BADZIPFILE;   
+    return EXTRACTOR_UNZIP_BADZIPFILE;
   if ( (EXTRACTOR_UNZIP_OK !=
        read_short_from_ffd (&file->z_filefunc, &uData)) ||
        (EXTRACTOR_UNZIP_OK !=
@@ -1195,7 +1195,7 @@ parse_current_file_coherency_header (struct 
EXTRACTOR_UnzipFile *file,
     return EXTRACTOR_UNZIP_BADZIPFILE;
   if ( (0 != file->cur_file_info.compression_method) &&
        (Z_DEFLATED != file->cur_file_info.compression_method) )
-    return EXTRACTOR_UNZIP_BADZIPFILE;  
+    return EXTRACTOR_UNZIP_BADZIPFILE;
   if (EXTRACTOR_UNZIP_OK !=
       read_long_from_ffd (&file->z_filefunc, &uData)) /* date/time */
     return EXTRACTOR_UNZIP_ERRNO;
@@ -1222,7 +1222,7 @@ parse_current_file_coherency_header (struct 
EXTRACTOR_UnzipFile *file,
       read_short_from_ffd (&file->z_filefunc, &size_filename))
     return EXTRACTOR_UNZIP_ERRNO;
   if (size_filename != file->cur_file_info.size_filename)
-    return EXTRACTOR_UNZIP_BADZIPFILE;  
+    return EXTRACTOR_UNZIP_BADZIPFILE;
   *piSizeVar += (uInt) size_filename;
   if (EXTRACTOR_UNZIP_OK !=
       read_short_from_ffd (&file->z_filefunc,
@@ -1232,7 +1232,7 @@ parse_current_file_coherency_header (struct 
EXTRACTOR_UnzipFile *file,
     SIZEZIPLOCALHEADER + size_filename;
   *psize_local_extrafield = (uInt) size_extra_field;
   *piSizeVar += (uInt)size_extra_field;
-  
+
   return EXTRACTOR_UNZIP_OK;
 }
 
@@ -1241,9 +1241,9 @@ parse_current_file_coherency_header (struct 
EXTRACTOR_UnzipFile *file,
  * Open for reading data the current file in the zipfile.
  *
  * @param file zipfile to manipulate
- * @return EXTRACTOR_UNZIP_OK on success
+ * @return #EXTRACTOR_UNZIP_OK on success
  */
-int 
+int
 EXTRACTOR_common_unzip_open_current_file (struct EXTRACTOR_UnzipFile *file)
 {
   int err;
@@ -1251,7 +1251,7 @@ EXTRACTOR_common_unzip_open_current_file (struct 
EXTRACTOR_UnzipFile *file)
   struct FileInZipReadInfo *pfile_in_zip_read_info;
   uLong offset_local_extrafield;  /* offset of the local extra field */
   uInt  size_local_extrafield;    /* size of the local extra field */
-  
+
   if (NULL == file)
     return EXTRACTOR_UNZIP_PARAMERROR;
   if (! file->current_file_ok)
@@ -1259,7 +1259,7 @@ EXTRACTOR_common_unzip_open_current_file (struct 
EXTRACTOR_UnzipFile *file)
   if (NULL != file->pfile_in_zip_read)
     EXTRACTOR_common_unzip_close_current_file (file);
   if (EXTRACTOR_UNZIP_OK !=
-      parse_current_file_coherency_header (file, 
+      parse_current_file_coherency_header (file,
                                           &iSizeVar,
                                           &offset_local_extrafield,
                                           &size_local_extrafield))
@@ -1283,7 +1283,7 @@ EXTRACTOR_common_unzip_open_current_file (struct 
EXTRACTOR_UnzipFile *file)
       // FIXME: we don't do anything with this 'err' code.
       // Can this happen? Should we abort in this case?
     }
-  
+
   pfile_in_zip_read_info->crc32_wait = file->cur_file_info.crc;
   pfile_in_zip_read_info->crc32 = 0;
   pfile_in_zip_read_info->compression_method = 
file->cur_file_info.compression_method;
@@ -1332,16 +1332,16 @@ EXTRACTOR_common_unzip_open_current_file (struct 
EXTRACTOR_UnzipFile *file)
  * @param size number of bytes desired
  * @return number of bytes copied to buf
  */
-static uLong 
+static uLong
 ec_read_file_func (voidpf opaque,
                   void* buf,
-                  uLong size) 
+                  uLong size)
 {
   struct EXTRACTOR_ExtractContext *ec = opaque;
   void *ptr;
   ssize_t ret;
   uLong done;
-  
+
   done = 0;
   while (done < size)
     {
@@ -1363,7 +1363,7 @@ ec_read_file_func (voidpf opaque,
  * @param opaque the 'struct EXTRACTOR_ExtractContext'
  * @return current offset in file, -1 on error
  */
-static long 
+static long
 ec_tell_file_func (voidpf opaque)
 {
   struct EXTRACTOR_ExtractContext *ec = opaque;
@@ -1378,15 +1378,15 @@ ec_tell_file_func (voidpf opaque)
  * @param opaque the 'struct EXTRACTOR_ExtractContext'
  * @param offset where to seek
  * @param origin relative to where should we seek
- * @return EXTRACTOR_UNZIP_OK on success
+ * @return #EXTRACTOR_UNZIP_OK on success
  */
-static long 
-ec_seek_file_func (voidpf opaque,                                         
+static long
+ec_seek_file_func (voidpf opaque,
                   uLong offset,
-                  int origin) 
+                  int origin)
 {
   struct EXTRACTOR_ExtractContext *ec = opaque;
-  
+
   if (-1 == ec->seek (ec->cls, offset, origin))
     return EXTRACTOR_UNZIP_INTERNALERROR;
   return EXTRACTOR_UNZIP_OK;
@@ -1400,7 +1400,7 @@ ec_seek_file_func (voidpf opaque,
  * @param ec extract context to use
  * @return handle to zip data, NULL on error
  */
-struct EXTRACTOR_UnzipFile * 
+struct EXTRACTOR_UnzipFile *
 EXTRACTOR_common_unzip_open (struct EXTRACTOR_ExtractContext *ec)
 {
   struct FileFuncDefs ffd;
diff --git a/src/main/extract.c b/src/main/extract.c
index fd7cc962..2492fa92 100644
--- a/src/main/extract.c
+++ b/src/main/extract.c
@@ -79,16 +79,16 @@ ignore_sigpipe ()
 /**
  * Information about command-line options.
  */
-struct Help 
+struct Help
 {
   /**
    * Single-character option name, '\0' for none.
-   */ 
+   */
   char shortArg;
-  
+
   /**
    * Long name of the option.
-   */ 
+   */
   const char * longArg;
 
   /**
@@ -116,10 +116,10 @@ struct Help
  * @param description program description
  * @param opt program options (NULL-terminated array)
  */
-static void 
+static void
 format_help (const char *general,
             const char *description,
-            const struct Help *opt) 
+            const struct Help *opt)
 {
   size_t slen;
   unsigned int i;
@@ -128,14 +128,14 @@ format_help (const char *general,
   size_t p;
   char scp[80];
   const char *trans;
-       
+
   printf (_("Usage: %s\n%s\n\n"),
          gettext(general),
          gettext(description));
   printf (_("Arguments mandatory for long options are also mandatory for short 
options.\n"));
   slen = 0;
   i = 0;
-  while (NULL != opt[i].description) 
+  while (NULL != opt[i].description)
     {
       if (0 == opt[i].shortArg)
        printf ("      ");
@@ -145,18 +145,18 @@ format_help (const char *general,
       printf ("--%s",
              opt[i].longArg);
       slen = 8 + strlen(opt[i].longArg);
-      if (NULL != opt[i].mandatoryArg) 
+      if (NULL != opt[i].mandatoryArg)
        {
          printf ("=%s",
                  opt[i].mandatoryArg);
          slen += 1+strlen(opt[i].mandatoryArg);
        }
-      if (slen > BORDER) 
+      if (slen > BORDER)
        {
          printf ("\n%*s", BORDER, "");
          slen = BORDER;
        }
-      if (slen < BORDER) 
+      if (slen < BORDER)
        {
          printf ("%*s", (int) (BORDER - slen), "");
          slen = BORDER;
@@ -165,7 +165,7 @@ format_help (const char *general,
       ml = strlen(trans);
       p = 0;
     OUTER:
-      while (ml - p > 78 - slen) 
+      while (ml - p > 78 - slen)
        {
          for (j=p+78-slen;j>p;j--)
            {
@@ -192,7 +192,7 @@ format_help (const char *general,
          printf ("%s\n%*s",
                  scp,
                  BORDER+2,
-                 "");  
+                 "");
          slen = BORDER+2;
          p = p + 78 - slen;
        }
@@ -211,7 +211,7 @@ format_help (const char *general,
 static void
 print_help ()
 {
-  static struct Help help[] = 
+  static struct Help help[] =
     {
       { 'b', "bibtex", NULL,
        gettext_noop("print output in bibtex format") },
@@ -258,13 +258,13 @@ print_help ()
  *        used in the main libextractor library and yielding
  *        meta data).
  * @param type libextractor-type describing the meta data
- * @param format basic format information about data 
+ * @param format basic format information about data
  * @param data_mime_type mime-type of data (not of the original file);
  *        can be NULL (if mime-type is not known)
  * @param data actual meta-data found
  * @param data_len number of bytes in data
  * @return 0 to continue extracting, 1 to abort
- */ 
+ */
 static int
 print_selected_keywords (void *cls,
                         const char *plugin_name,
@@ -273,7 +273,7 @@ print_selected_keywords (void *cls,
                         const char *data_mime_type,
                         const char *data,
                         size_t data_len)
-{ 
+{
   char *keyword;
 #if HAVE_ICONV
   iconv_t cd;
@@ -298,6 +298,8 @@ print_selected_keywords (void *cls,
               (unsigned int) data_len);
       break;
     case EXTRACTOR_METAFORMAT_UTF8:
+      if (0 == data_len)
+        break;
 #if HAVE_ICONV
       cd = iconv_open (nl_langinfo(CODESET), "UTF-8");
       if (((iconv_t) -1) != cd)
@@ -306,7 +308,7 @@ print_selected_keywords (void *cls,
                                data_len);
       else
 #endif
-       keyword = strdup (data);
+        keyword = strdup (data);
       if (NULL != keyword)
        {
          FPRINTF (stdout,
@@ -349,13 +351,13 @@ print_selected_keywords (void *cls,
  *        used in the main libextractor library and yielding
  *        meta data).
  * @param type libextractor-type describing the meta data
- * @param format basic format information about data 
+ * @param format basic format information about data
  * @param data_mime_type mime-type of data (not of the original file);
  *        can be NULL (if mime-type is not known)
  * @param data actual meta-data found
  * @param data_len number of bytes in data
  * @return 0 to continue extracting, 1 to abort
- */ 
+ */
 static int
 print_selected_keywords_grep_friendly (void *cls,
                                       const char *plugin_name,
@@ -364,9 +366,9 @@ print_selected_keywords_grep_friendly (void *cls,
                                       const char *data_mime_type,
                                       const char *data,
                                       size_t data_len)
-{ 
+{
   char *keyword;
-#if HAVE_ICONV 
+#if HAVE_ICONV
   iconv_t cd;
 #endif
   const char *mt;
@@ -378,14 +380,16 @@ print_selected_keywords_grep_friendly (void *cls,
     mt = gettext_noop ("unknown");
   switch (format)
     {
-    case EXTRACTOR_METAFORMAT_UNKNOWN:      
+    case EXTRACTOR_METAFORMAT_UNKNOWN:
       break;
     case EXTRACTOR_METAFORMAT_UTF8:
+      if (0 == data_len)
+        return 0;
       if (verbose > 1)
        FPRINTF (stdout,
                 "%s: ",
                 gettext(mt));
-#if HAVE_ICONV 
+#if HAVE_ICONV
       cd = iconv_open (nl_langinfo (CODESET), "UTF-8");
       if (((iconv_t) -1) != cd)
        keyword = iconv_helper (cd,
@@ -401,7 +405,7 @@ print_selected_keywords_grep_friendly (void *cls,
                   keyword);
          free (keyword);
        }
-#if HAVE_ICONV 
+#if HAVE_ICONV
       if (((iconv_t) -1) != cd)
        iconv_close (cd);
 #endif
@@ -474,7 +478,7 @@ static struct BibTexMap btm[] =
     { "institution", EXTRACTOR_METATYPE_PUBLISHER_INSTITUTION, NULL },
     { "series", EXTRACTOR_METATYPE_PUBLISHER_SERIES, NULL},
     { "month", EXTRACTOR_METATYPE_PUBLICATION_MONTH, NULL },
-    { "url", EXTRACTOR_METATYPE_URL, NULL}, 
+    { "url", EXTRACTOR_METATYPE_URL, NULL},
     { "note", EXTRACTOR_METATYPE_COMMENT, NULL},
     { "eprint", EXTRACTOR_METATYPE_BIBTEX_EPRINT, NULL },
     { "type", EXTRACTOR_METATYPE_PUBLICATION_TYPE, NULL },
@@ -485,11 +489,11 @@ static struct BibTexMap btm[] =
 /**
  * Clean up the bibtex processor in preparation for the next round.
  */
-static void 
+static void
 cleanup_bibtex ()
 {
   unsigned int i;
-  
+
   for (i = 0; NULL != btm[i].bibTexName; i++)
     {
       free (btm[i].value);
@@ -509,7 +513,7 @@ cleanup_bibtex ()
  *        used in the main libextractor library and yielding
  *        meta data).
  * @param type libextractor-type describing the meta data
- * @param format basic format information about data 
+ * @param format basic format information about data
  * @param data_mime_type mime-type of data (not of the original file);
  *        can be NULL (if mime-type is not known)
  * @param data actual meta-data found
@@ -527,6 +531,8 @@ print_bibtex (void *cls,
 {
   unsigned int i;
 
+  if (0 == data_len)
+    return 0;
   if (YES != print[type])
     return 0;
   if (EXTRACTOR_METAFORMAT_UTF8 != format)
@@ -563,7 +569,7 @@ finish_bibtex (const char *fn)
     et = "misc";
   if ( (NULL == btm[0].value) ||
        (NULL == btm[1].value) ||
-       (NULL == btm[2].value) )          
+       (NULL == btm[2].value) )
     FPRINTF (stdout,
             "@%s %s { ",
             et,
@@ -577,9 +583,9 @@ finish_bibtex (const char *fn)
                btm[1].value,
                btm[0].value);
       for (n=strlen (temp)-1;n>=0;n-- )
-       if (! isalnum ( (unsigned char) temp[n]) ) 
+       if (! isalnum ( (unsigned char) temp[n]) )
          temp[n] = '_';
-       else 
+       else
          temp[n] = tolower ( (unsigned char) temp[n]);
       FPRINTF (stdout,
               "@%s %s { ",
@@ -587,7 +593,7 @@ finish_bibtex (const char *fn)
               temp);
     }
   for (i=0; NULL != btm[i].bibTexName; i++)
-    if (NULL != btm[i].value) 
+    if (NULL != btm[i].value)
       FPRINTF (stdout,
               "\t%s = {%s},\n",
               btm[i].bibTexName,
@@ -610,9 +616,9 @@ _wchar_to_str (const wchar_t *wstr, char **retstr, UINT cp)
   error = GetLastError ();
   if (len <= 0)
     return -1;
-  
+
   str = malloc (sizeof (char) * len);
-  
+
   SetLastError (0);
   lenc = WideCharToMultiByte (cp, 0, wstr, -1, str, len, NULL, (cp == CP_UTF8 
|| cp == CP_UTF7) ? NULL : &lossy);
   error = GetLastError ();
@@ -758,7 +764,7 @@ main (int argc, char *argv[])
 #endif
   if (NULL == (print = malloc (sizeof (int) * EXTRACTOR_metatype_get_max ())))
     {
-      FPRINTF (stderr, 
+      FPRINTF (stderr,
               "malloc failed: %s\n",
               strerror (errno));
       return 1;
@@ -791,7 +797,7 @@ main (int argc, char *argv[])
       };
       option_index = 0;
       c = getopt_long (utf8_argc,
-                      utf8_argv, 
+                      utf8_argv,
                       "abghiml:Lnp:vVx:",
                       long_options,
                       &option_index);
@@ -848,7 +854,7 @@ main (int argc, char *argv[])
          nodefault = YES;
          break;
        case 'p':
-         if (NULL == optarg) 
+         if (NULL == optarg)
            {
              FPRINTF(stderr,
                      _("You must specify an argument for the `%s' option 
(option ignored).\n"),
@@ -865,11 +871,11 @@ main (int argc, char *argv[])
          i = 0;
          while (NULL != EXTRACTOR_metatype_to_string (i))
            {
-             if ( (0 == strcmp (optarg, 
+             if ( (0 == strcmp (optarg,
                                 EXTRACTOR_metatype_to_string (i))) ||
-                  (0 == strcmp (optarg, 
+                  (0 == strcmp (optarg,
                                 gettext(EXTRACTOR_metatype_to_string (i)))) )
-               
+
                {
                  print[i] = YES;
                  break;
@@ -897,9 +903,9 @@ main (int argc, char *argv[])
          i = 0;
          while (NULL != EXTRACTOR_metatype_to_string (i))
            {
-             if ( (0 == strcmp (optarg, 
+             if ( (0 == strcmp (optarg,
                                 EXTRACTOR_metatype_to_string (i))) ||
-                  (0 == strcmp (optarg, 
+                  (0 == strcmp (optarg,
                                 gettext(EXTRACTOR_metatype_to_string (i)))) )
                {
                  print[i] = NO;
@@ -950,7 +956,7 @@ main (int argc, char *argv[])
   else
     plugins = NULL;
   if (NULL != libraries)
-    plugins = EXTRACTOR_plugin_add_config (plugins, 
+    plugins = EXTRACTOR_plugin_add_config (plugins,
                                           libraries,
                                           in_process
                                           ? EXTRACTOR_OPTION_IN_PROCESS
@@ -962,7 +968,7 @@ main (int argc, char *argv[])
   if (YES == bibtex)
     FPRINTF(stdout,
            "%s", _("% BiBTeX file\n"));
-  for (i = optind; i < utf8_argc; i++) 
+  for (i = optind; i < utf8_argc; i++)
     {
       errno = 0;
       if (YES == grepfriendly)
@@ -1001,7 +1007,7 @@ main (int argc, char *argv[])
            }
          else
            {
-             if (verbose > 0) 
+             if (verbose > 0)
                FPRINTF(stderr,
                        "%s: %s: %s\n",
                        utf8_argv[0], utf8_argv[i], strerror(errno));
diff --git a/src/main/extractor.c b/src/main/extractor.c
index b51af84b..11ace464 100644
--- a/src/main/extractor.c
+++ b/src/main/extractor.c
@@ -360,7 +360,7 @@ in_process_proc (void *cls,
  *        all plugins are in-process)
  * @param ds data to process
  * @param proc function to call for each meta data item found
- * @param proc_cls cls argument to proc
+ * @param proc_cls cls argument to @a proc
  */
 static void
 do_extract (struct EXTRACTOR_PluginList *plugins,
@@ -387,9 +387,14 @@ do_extract (struct EXTRACTOR_PluginList *plugins,
   for (pos = plugins; NULL != pos; pos = pos->next)
     plugin_count++;
   if (NULL != shm)
-    ready = EXTRACTOR_IPC_shared_memory_set_ (shm, ds, 0, DEFAULT_SHM_SIZE);
+    ready = EXTRACTOR_IPC_shared_memory_set_ (shm,
+                                              ds,
+                                              0,
+                                              DEFAULT_SHM_SIZE);
   else
     ready = 0;
+  if (-1 == ready)
+    return; /* failed to ready _any_ data!? */
   have_in_memory = 0;
   prp.file_finished = 0;
   prp.proc = proc;
@@ -500,7 +505,8 @@ do_extract (struct EXTRACTOR_PluginList *plugins,
        }
       data_available = -1;
       if ( (1 == done) &&
-          (-1 != min_seek) )
+          (-1 != min_seek) &&
+           (NULL != shm) )
        {
          /* current position done, but seek requested */
          done = 0;
@@ -642,6 +648,7 @@ EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins,
     }
   for (pos = plugins; NULL != pos; pos = pos->next)
     if ( (NULL == pos->channel) &&
+         (NULL != shm) &&
         (EXTRACTOR_OPTION_IN_PROCESS != pos->flags) )
       {
        if (NULL == pos->shm)
@@ -652,7 +659,11 @@ EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins,
        pos->channel = EXTRACTOR_IPC_channel_create_ (pos,
                                                      shm);
       }
-  do_extract (plugins, shm, datasource, proc, proc_cls);
+  do_extract (plugins,
+              shm,
+              datasource,
+              proc,
+              proc_cls);
   EXTRACTOR_datasource_destroy_ (datasource);
 }
 
diff --git a/src/main/extractor_datasource.c b/src/main/extractor_datasource.c
index 8b4c6113..888e524a 100644
--- a/src/main/extractor_datasource.c
+++ b/src/main/extractor_datasource.c
@@ -462,6 +462,7 @@ cfs_init_decompressor_zlib (struct CompressedFileSource 
*cfs,
 {
   unsigned int gzip_header_length = 10;
   unsigned char hdata[12];
+  ssize_t rsize;
 
   if (0 != bfds_seek (cfs->bfds, 0, SEEK_SET))
     {
@@ -469,7 +470,9 @@ cfs_init_decompressor_zlib (struct CompressedFileSource 
*cfs,
       return -1;
     }
   /* Process gzip header */
-  if (sizeof (hdata) > bfds_read (cfs->bfds, hdata, sizeof (hdata)))
+  rsize = bfds_read (cfs->bfds, hdata, sizeof (hdata));
+  if ( (-1 == rsize) ||
+       (sizeof (hdata) > (size_t) rsize) )
     return -1;
   if (0 != (hdata[3] & 0x4)) /* FEXTRA  set */
     gzip_header_length += 2 + (hdata[10] & 0xff) + ((hdata[11] & 0xff) * 256);
diff --git a/src/main/extractor_ipc_gnu.c b/src/main/extractor_ipc_gnu.c
index 7d597048..7eedfc71 100644
--- a/src/main/extractor_ipc_gnu.c
+++ b/src/main/extractor_ipc_gnu.c
@@ -158,14 +158,18 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size)
   if (-1 == (shm->shm_id = shm_open (shm->shm_name,
                                     O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)))
     {
-      LOG_STRERROR_FILE ("shm_open", shm->shm_name);
+      LOG_STRERROR_FILE ("shm_open",
+                         shm->shm_name);
       free (shm);
       return NULL;
     }
   if ( (0 != ftruncate (shm->shm_id, size)) ||
-       (NULL == (shm->shm_ptr = mmap (NULL, size,
-                                     PROT_WRITE, MAP_SHARED,
-                                     shm->shm_id, 0))) ||
+       (NULL == (shm->shm_ptr = mmap (NULL,
+                                      size,
+                                     PROT_WRITE,
+                                      MAP_SHARED,
+                                     shm->shm_id,
+                                      0))) ||
        (((void*) -1) == shm->shm_ptr) )
   {
     LOG_STRERROR ("ftruncate/mmap");
@@ -205,7 +209,8 @@ EXTRACTOR_IPC_shared_memory_change_rc_ (struct 
EXTRACTOR_SharedMemory *shm,
 void
 EXTRACTOR_IPC_shared_memory_destroy_ (struct EXTRACTOR_SharedMemory *shm)
 {
-  munmap (shm->shm_ptr, shm->shm_size);
+  munmap (shm->shm_ptr,
+          shm->shm_size);
   (void) close (shm->shm_id);
   (void) shm_unlink (shm->shm_name);
   free (shm);
@@ -228,7 +233,9 @@ EXTRACTOR_IPC_shared_memory_set_ (struct 
EXTRACTOR_SharedMemory *shm,
                                  size_t size)
 {
   if (-1 ==
-      EXTRACTOR_datasource_seek_ (ds, off, SEEK_SET))
+      EXTRACTOR_datasource_seek_ (ds,
+                                  off,
+                                  SEEK_SET))
     {
       LOG ("Failed to set IPC memory due to seek error\n");
       return -1;
@@ -250,7 +257,10 @@ EXTRACTOR_IPC_shared_memory_set_ (struct 
EXTRACTOR_SharedMemory *shm,
 uint64_t
 EXTRACTOR_datasource_get_pos_ (struct EXTRACTOR_Datasource *ds)
 {
-  int64_t pos = EXTRACTOR_datasource_seek_ (ds, 0, SEEK_CUR);
+  int64_t pos = EXTRACTOR_datasource_seek_ (ds,
+                                            0,
+                                            SEEK_CUR);
+
   if (-1 == pos)
     return UINT_MAX;
   return pos;
@@ -525,6 +535,7 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel 
**channels,
              LOG ("Inbound message from channel too large, aborting\n");
              EXTRACTOR_IPC_channel_destroy_ (channel);
              channels[i] = NULL;
+              continue;
            }
          channel->mdata_size *= 2;
          if (channel->mdata_size > MAX_META_DATA)
@@ -535,6 +546,7 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel 
**channels,
              LOG_STRERROR ("realloc");
              EXTRACTOR_IPC_channel_destroy_ (channel);
              channels[i] = NULL;
+              continue;
            }
          channel->mdata = ndata;
        }
@@ -553,6 +565,7 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel 
**channels,
                channel->plugin->libname);
          EXTRACTOR_IPC_channel_destroy_ (channel);
          channels[i] = NULL;
+          continue;
        }
       else
        {
diff --git a/src/main/extractor_plugins.c b/src/main/extractor_plugins.c
index 24bb0640..8dc53d22 100644
--- a/src/main/extractor_plugins.c
+++ b/src/main/extractor_plugins.c
@@ -50,7 +50,7 @@ get_symbol_with_prefix (void *lib_handle,
   char *dot;
   const char *(*opt_fun)(void);
 
-  if (NULL != options) 
+  if (NULL != options)
     *options = NULL;
   if (NULL == (sym_name = strrchr (prefix, '_')))
     return NULL;
@@ -72,7 +72,7 @@ get_symbol_with_prefix (void *lib_handle,
          sym);
   /* try without '_' first */
   symbol = lt_dlsym (lib_handle, name + 1);
-  if (NULL == symbol) 
+  if (NULL == symbol)
     {
       /* now try with the '_' */
       char *first_error = strdup (lt_dlerror ());
@@ -100,9 +100,9 @@ get_symbol_with_prefix (void *lib_handle,
               sym);
       /* try without '_' first */
       opt_fun = lt_dlsym (lib_handle, name + 1);
-      if (NULL == opt_fun) 
+      if (NULL == opt_fun)
        opt_fun = lt_dlsym (lib_handle, name);
-      if (NULL != opt_fun)     
+      if (NULL != opt_fun)
        *options = opt_fun ();
     }
   free (sym);
@@ -143,7 +143,7 @@ EXTRACTOR_plugin_load_ (struct EXTRACTOR_PluginList *plugin)
 #if WINDOWS
   wlibname[0] = L'\0';
   llibname[0] = '\0';
-  if ( (MultiByteToWideChar (CP_UTF8, 0, plugin->libname, -1, 
+  if ( (MultiByteToWideChar (CP_UTF8, 0, plugin->libname, -1,
                             wlibname, sizeof (wlibname)) <= 0) ||
        (WideCharToMultiByte (CP_ACP, 0, wlibname, -1,
                             llibname, sizeof (llibname), NULL, NULL) < 0) )
@@ -159,7 +159,7 @@ EXTRACTOR_plugin_load_ (struct EXTRACTOR_PluginList *plugin)
   plugin->libraryHandle = lt_dlopenadvise (llibname,
                                           advise);
 #else
-  plugin->libraryHandle = lt_dlopenadvise (plugin->libname, 
+  plugin->libraryHandle = lt_dlopenadvise (plugin->libname,
                                           advise);
 #endif
   lt_dladvise_destroy (&advise);
@@ -178,7 +178,7 @@ EXTRACTOR_plugin_load_ (struct EXTRACTOR_PluginList *plugin)
                                                   
"_EXTRACTOR_%s_extract_method",
                                                   plugin->libname,
                                                   &plugin->specials);
-  if (NULL == plugin->extract_method) 
+  if (NULL == plugin->extract_method)
     {
       LOG ("Resolving `extract' method of plugin `%s' failed: %s\n",
           plugin->short_libname,
@@ -286,17 +286,17 @@ EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList 
*prev,
        case '(':
          cpy[pos++] = '\0';    /* replace '(' by termination */
          lastconf = pos;         /* start config from here, after (. */
-         while ( ('\0' != cpy[pos]) && 
+         while ( ('\0' != cpy[pos]) &&
                  (')' != cpy[pos]))
            pos++; /* config until ) or EOS. */
-         if (')' == cpy[pos]) 
+         if (')' == cpy[pos])
            {
              cpy[pos++] = '\0'; /* write end of config here. */
-             while ( (':' != cpy[pos]) && 
+             while ( (':' != cpy[pos]) &&
                      ('\0' != cpy[pos]) )
                pos++; /* forward until real end of string found. */
              cpy[pos++] = '\0';
-           } 
+           }
          else
            {
              cpy[pos++] = '\0'; /* end of string. */
@@ -313,13 +313,13 @@ EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList 
*prev,
       if ('-' == cpy[last])
        {
          last++;
-         prev = EXTRACTOR_plugin_remove (prev, 
+         prev = EXTRACTOR_plugin_remove (prev,
                                          &cpy[last]);
        }
       else
        {
-         prev = EXTRACTOR_plugin_add (prev, 
-                                      &cpy[last], 
+         prev = EXTRACTOR_plugin_add (prev,
+                                      &cpy[last],
                                       (-1 != lastconf) ? &cpy[lastconf] : NULL,
                                       flags);
        }
@@ -346,7 +346,7 @@ EXTRACTOR_plugin_remove (struct EXTRACTOR_PluginList *prev,
 
   pos = prev;
   first = prev;
-  while ( (NULL != pos) && 
+  while ( (NULL != pos) &&
          (0 != strcmp (pos->short_libname, library)) )
     {
       prev = pos;
@@ -368,11 +368,11 @@ EXTRACTOR_plugin_remove (struct EXTRACTOR_PluginList 
*prev,
   if ( (NULL != pos->shm) &&
        (0 == EXTRACTOR_IPC_shared_memory_change_rc_ (pos->shm, -1)) )
     EXTRACTOR_IPC_shared_memory_destroy_ (pos->shm);
-  free (pos->short_libname);
-  free (pos->libname);
+  if (NULL != pos->libname)
+    free (pos->libname);
   free (pos->plugin_options);
-  if (NULL != pos->libraryHandle) 
-       lt_dlclose (pos->libraryHandle);      
+  if (NULL != pos->libraryHandle)
+       lt_dlclose (pos->libraryHandle);
   free (pos);
   return first;
 }
@@ -383,7 +383,7 @@ EXTRACTOR_plugin_remove (struct EXTRACTOR_PluginList *prev,
  *
  * @param plugin the list of plugins
  */
-void 
+void
 EXTRACTOR_plugin_remove_all (struct EXTRACTOR_PluginList *plugins)
 {
   while (NULL != plugins)
diff --git a/src/main/extractor_plugpath.c b/src/main/extractor_plugpath.c
index 234d80d5..461f25e4 100644
--- a/src/main/extractor_plugpath.c
+++ b/src/main/extractor_plugpath.c
@@ -218,8 +218,9 @@ get_path_from_module_filename ()
  * @param number of bytes available in 'buf'
  * @return 0 on success, otherwise desired number of bytes is stored in 
'bufsize'
  */
-typedef int (*MyNSGetExecutablePathProto) (char *buf,
-                                          size_t *bufsize);
+typedef int
+(*MyNSGetExecutablePathProto) (char *buf,
+                               size_t *bufsize);
 
 
 /**
diff --git a/src/plugins/deb_extractor.c b/src/plugins/deb_extractor.c
index 0f9fab1c..2eb00280 100644
--- a/src/plugins/deb_extractor.c
+++ b/src/plugins/deb_extractor.c
@@ -19,7 +19,7 @@
  */
 /**
  * @file plugins/deb_extractor.c
- * @brief plugin to support Debian archives 
+ * @brief plugin to support Debian archives
  * @author Christian Grothoff
  *
  * The .deb is an ar-chive file.  It contains a tar.gz file
@@ -86,7 +86,7 @@ struct Matches
 /**
  * Map from deb-control entries to LE types.
  *
- * see also: "man 5 deb-control" 
+ * see also: "man 5 deb-control"
  */
 static struct Matches tmap[] = {
   {"Package: ",       EXTRACTOR_METATYPE_PACKAGE_NAME},
@@ -131,7 +131,7 @@ processControl (const char *data,
   size_t colon;
   size_t eol;
   unsigned int i;
-  
+
   pos = 0;
   while (pos < size)
     {
@@ -159,7 +159,7 @@ processControl (const char *data,
              free (key);
              return 0;
            }
-         if (0 != proc (proc_cls, 
+         if (0 != proc (proc_cls,
                         "deb",
                         tmap[i].type,
                         EXTRACTOR_METAFORMAT_UTF8,
@@ -190,7 +190,7 @@ struct TarHeader
    * Filename.
    */
   char name[100];
- 
+
   /**
    * File access modes.
    */
@@ -210,7 +210,7 @@ struct TarHeader
    * Size of the file, in octal.
    */
   char filesize[12];
-  
+
   /**
    * Last modification time.
    */
@@ -363,6 +363,10 @@ processControlTGZ (struct EXTRACTOR_ExtractContext *ec,
 
   if (size > MAX_CONTROL_SIZE)
     return 0;
+  if (0 == size)
+    return 0;
+  if (size < 4)
+    return 0;
   if (NULL == (cdata = malloc (size)))
     return 0;
   off = 0;
@@ -373,7 +377,9 @@ processControlTGZ (struct EXTRACTOR_ExtractContext *ec,
          free (cdata);
          return 0;
        }
-      memcpy (&cdata[off], data, sret);
+      memcpy (&cdata[off],
+              data,
+              sret);
       off += sret;
     }
   bufSize = cdata[size - 4] + (cdata[size - 3] << 8) + (cdata[size - 2] << 16) 
+ (cdata[size - 1] << 24);
@@ -392,12 +398,12 @@ processControlTGZ (struct EXTRACTOR_ExtractContext *ec,
   strm.next_in = (Bytef *) data;
   strm.avail_in = size;
   if (Z_OK == inflateInit2 (&strm, 15 + 32))
-    {  
+    {
       strm.next_out = (Bytef *) buf;
       strm.avail_out = bufSize;
       inflate (&strm, Z_FINISH);
       if (strm.total_out > 0)
-       ret = processControlTar (buf, strm.total_out, 
+       ret = processControlTar (buf, strm.total_out,
                                 ec->proc, ec->cls);
       inflateEnd (&strm);
     }
@@ -450,11 +456,11 @@ struct ObjectHeader
 
 
 /**
- * Main entry method for the DEB extraction plugin.  
+ * Main entry method for the DEB extraction plugin.
  *
  * @param ec extraction context provided to the plugin
  */
-void 
+void
 EXTRACTOR_deb_extract_method (struct EXTRACTOR_ExtractContext *ec)
 {
   uint64_t pos;
@@ -493,7 +499,7 @@ EXTRACTOR_deb_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
       if ((pos + csize > fsize) || (csize > fsize) || (pos + csize < pos))
         return;
       if (0 == strncmp (&hdr->name[0],
-                        "control.tar.gz", 
+                        "control.tar.gz",
                        strlen ("control.tar.gz")))
         {
          if (0 != processControlTGZ (ec,
@@ -504,7 +510,7 @@ EXTRACTOR_deb_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
       if (0 == strncmp (&hdr->name[0],
                         "debian-binary", strlen ("debian-binary")))
         {
-         if (0 != ec->proc (ec->cls, 
+         if (0 != ec->proc (ec->cls,
                             "deb",
                             EXTRACTOR_METATYPE_MIMETYPE,
                             EXTRACTOR_METAFORMAT_UTF8,
diff --git a/src/plugins/gstreamer_extractor.c 
b/src/plugins/gstreamer_extractor.c
index 8bffd970..31568a72 100644
--- a/src/plugins/gstreamer_extractor.c
+++ b/src/plugins/gstreamer_extractor.c
@@ -1038,17 +1038,23 @@ send_structure_foreach (GQuark field_id,
   switch (ps->st)
   {
   case STREAM_TYPE_AUDIO:
+    if (NULL == audio_quarks)
+      return FALSE;
     for (quark = audio_quarks; *quark != 0; quark++)
       if (*quark == field_id)
         return TRUE;
     break;
   case STREAM_TYPE_VIDEO:
   case STREAM_TYPE_IMAGE:
+    if (NULL == video_quarks)
+      return FALSE;
     for (quark = video_quarks; *quark != 0; quark++)
       if (*quark == field_id)
         return TRUE;
     break;
   case STREAM_TYPE_SUBTITLE:
+    if (NULL == subtitle_quarks)
+      return FALSE;
     for (quark = subtitle_quarks; *quark != 0; quark++)
       if (*quark == field_id)
         return TRUE;
@@ -1078,8 +1084,11 @@ send_structure_foreach (GQuark field_id,
     /* This is a potential source of invalid characters */
     /* And it also might attempt to serialize binary data - such as images. */
     str = gst_value_serialize (value);
-    g_free (str);
-    str = NULL;
+    if (NULL != str)
+    {
+      g_free (str);
+      str = NULL;
+    }
     break;
   }
   if (NULL != str)
@@ -1093,21 +1102,33 @@ send_structure_foreach (GQuark field_id,
                                            named_tags[i].le_type,
                                            EXTRACTOR_METAFORMAT_UTF8, 
"text/plain",
                                            (const char *) str, strlen (str) + 
1);
-         g_free (str);
-         str = NULL;
+          if (NULL != str)
+            {
+              g_free (str);
+              str = NULL;
+            }
          break;
        }
   }
   if (NULL != str)
   {
-    gchar *senddata = g_strdup_printf ("%s=%s", field_name, str);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-                                     EXTRACTOR_METATYPE_UNKNOWN, 
EXTRACTOR_METAFORMAT_UTF8, "text/plain",
-                                     (const char *) senddata,
-                                     strlen (senddata) + 1);
-    g_free (senddata);
+    gchar *senddata = g_strdup_printf ("%s=%s",
+                                       field_name,
+                                       str);
+    if (NULL != senddata)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          EXTRACTOR_METATYPE_UNKNOWN,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) senddata,
+                                          strlen (senddata) + 1);
+        g_free (senddata);
+      }
   }
-  g_free (str);
+  if (NULL != str)
+    g_free (str);
 
   return ! ps->time_to_leave;
 }
@@ -1141,10 +1162,17 @@ send_audio_info (GstDiscovererAudioInfo *info,
   if (u > 0)
   {
     tmp = g_strdup_printf ("%u", u);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_CHANNELS, EXTRACTOR_METAFORMAT_UTF8, "text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          EXTRACTOR_METATYPE_CHANNELS,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1153,10 +1181,17 @@ send_audio_info (GstDiscovererAudioInfo *info,
   if (u > 0)
   {
     tmp = g_strdup_printf ("%u", u);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_SAMPLE_RATE, EXTRACTOR_METAFORMAT_UTF8, "text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          EXTRACTOR_METATYPE_SAMPLE_RATE,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1165,10 +1200,17 @@ send_audio_info (GstDiscovererAudioInfo *info,
   if (u > 0)
   {
     tmp = g_strdup_printf ("%u", u);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_AUDIO_DEPTH, EXTRACTOR_METAFORMAT_UTF8, "text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          EXTRACTOR_METATYPE_AUDIO_DEPTH,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1177,10 +1219,17 @@ send_audio_info (GstDiscovererAudioInfo *info,
   if (u > 0)
   {
     tmp = g_strdup_printf ("%u", u);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_AUDIO_BITRATE, EXTRACTOR_METAFORMAT_UTF8, 
"text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          EXTRACTOR_METATYPE_AUDIO_BITRATE,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1189,10 +1238,17 @@ send_audio_info (GstDiscovererAudioInfo *info,
   if (u > 0)
   {
     tmp = g_strdup_printf ("%u", u);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE, EXTRACTOR_METAFORMAT_UTF8, 
"text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          
EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1221,10 +1277,17 @@ send_video_info (GstDiscovererVideoInfo *info,
   if ( (u > 0) && (u2 > 0) )
   {
     tmp = g_strdup_printf ("%ux%u", u, u2);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_VIDEO_DIMENSIONS, EXTRACTOR_METAFORMAT_UTF8, 
"text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1233,10 +1296,17 @@ send_video_info (GstDiscovererVideoInfo *info,
   if (u > 0)
   {
     tmp = g_strdup_printf ("%u", u);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_VIDEO_DEPTH, EXTRACTOR_METAFORMAT_UTF8, "text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          EXTRACTOR_METATYPE_VIDEO_DEPTH,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1246,10 +1316,17 @@ send_video_info (GstDiscovererVideoInfo *info,
   if ( (u > 0) && (u2 > 0) )
   {
     tmp = g_strdup_printf ("%u/%u", u, u2);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_FRAME_RATE, EXTRACTOR_METAFORMAT_UTF8, "text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          EXTRACTOR_METATYPE_FRAME_RATE,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1259,10 +1336,17 @@ send_video_info (GstDiscovererVideoInfo *info,
   if ( (u > 0) && (u2 > 0) )
   {
     tmp = g_strdup_printf ("%u/%u", u, u2);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO, EXTRACTOR_METAFORMAT_UTF8, 
"text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          
EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1273,10 +1357,17 @@ send_video_info (GstDiscovererVideoInfo *info,
   if (u > 0)
   {
     tmp = g_strdup_printf ("%u", u);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_VIDEO_BITRATE, EXTRACTOR_METAFORMAT_UTF8, 
"text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          EXTRACTOR_METATYPE_VIDEO_BITRATE,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1285,10 +1376,17 @@ send_video_info (GstDiscovererVideoInfo *info,
   if (u > 0)
   {
     tmp = g_strdup_printf ("%u", u);
-    ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-      EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE, EXTRACTOR_METAFORMAT_UTF8, 
"text/plain",
-      (const char *) tmp, strlen (tmp) + 1);
-    g_free (tmp);
+    if (NULL != tmp)
+      {
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          
EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) tmp,
+                                          strlen (tmp) + 1);
+        g_free (tmp);
+      }
     if (ps->time_to_leave)
       return TRUE;
   }
@@ -1442,8 +1540,11 @@ send_tag_foreach (const GstTagList * tags,
 
           buf = gst_sample_get_buffer (sample);
           gst_buffer_map (buf, &mi, GST_MAP_READ);
-          ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", le_type,
-              EXTRACTOR_METAFORMAT_BINARY, mime_type,
+          ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                            "gstreamer",
+                                            le_type,
+                                            EXTRACTOR_METAFORMAT_BINARY,
+                                            mime_type,
               (const char *) mi.data, mi.size);
           gst_buffer_unmap (buf, &mi);
         }
@@ -1564,7 +1665,8 @@ send_tag_foreach (const GstTagList * tags,
           if ((0 != strcmp (tag, "extended-comment")) || !strchr (str, '='))
           {
             new_str = g_strdup_printf ("%s=%s", tag, str);
-            g_free (str);
+            if (NULL != str)
+              g_free (str);
             str = new_str;
           }
         }
@@ -1572,13 +1674,18 @@ send_tag_foreach (const GstTagList * tags,
       default:
         break;
       }
-      if (!skip)
-        ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer", le_type,
-            EXTRACTOR_METAFORMAT_UTF8, "text/plain",
-            (const char *) str, strlen (str) + 1);
+      if ( (! skip) &&
+           (NULL != str) )
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          le_type,
+                                          EXTRACTOR_METAFORMAT_UTF8,
+                                          "text/plain",
+                                          (const char *) str,
+                                          strlen (str) + 1);
     }
-
-    g_free (str);
+    if (NULL != str)
+      g_free (str);
     g_value_unset (&val);
   }
 }
@@ -1730,24 +1837,39 @@ send_toc_tags_foreach (const GstTagList * tags,
     /* This is a potential source of invalid characters */
     /* And it also might attempt to serialize binary data - such as images. */
     str = gst_value_serialize (&val);
-    g_free (str);
-    str = NULL;
+    if (NULL != str)
+    {
+      g_free (str);
+      str = NULL;
+    }
     break;
   }
-  if (str != NULL)
+  if (NULL != str)
   {
-    topen = g_strdup_printf ("%*.*s<%s>", ps->toc_depth * 2,
-      ps->toc_depth * 2, " ", tag);
-    tclose = g_strdup_printf ("%*.*s</%s>\n", ps->toc_depth * 2,
-      ps->toc_depth * 2, " ", tag);
-
-    if (ps->toc_print_phase)
-      ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos],
-          ps->toc_length - ps->toc_pos, "%s%s%s", topen, str, tclose);
-    else
-      ps->toc_length += strlen (topen) + strlen (str) + strlen (tclose);
-    g_free (topen);
-    g_free (tclose);
+    topen = g_strdup_printf ("%*.*s<%s>",
+                             ps->toc_depth * 2,
+                             ps->toc_depth * 2, " ", tag);
+    tclose = g_strdup_printf ("%*.*s</%s>\n",
+                              ps->toc_depth * 2,
+                              ps->toc_depth * 2, " ",
+                              tag);
+    if ( (NULL != topen) &&
+         (NULL != tclose) )
+    {
+      if (ps->toc_print_phase)
+        ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos],
+                                   ps->toc_length - ps->toc_pos,
+                                   "%s%s%s",
+                                   topen,
+                                   str,
+                                   tclose);
+      else
+        ps->toc_length += strlen (topen) + strlen (str) + strlen (tclose);
+    }
+    if (NULL != topen)
+      g_free (topen);
+    if (NULL != tclose)
+      g_free (tclose);
     g_free (str);
   }
   g_value_unset (&val);
@@ -1780,11 +1902,17 @@ send_toc_foreach (gpointer data, gpointer user_data)
                       GST_TIME_FORMAT"\">\n", ps->toc_depth * 2, ps->toc_depth 
* 2, " ",
                       gst_toc_entry_type_get_nick (entype), GST_TIME_ARGS 
(start),
                       GST_TIME_ARGS (stop));
-  if (ps->toc_print_phase)
-    ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - 
ps->toc_pos, "%s", s);
-  else
-    ps->toc_length += strlen (s);
-  g_free (s);
+  if (NULL != s)
+  {
+    if (ps->toc_print_phase)
+      ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos],
+                                 ps->toc_length - ps->toc_pos,
+                                 "%s",
+                                 s);
+    else
+      ps->toc_length += strlen (s);
+    g_free (s);
+  }
   ps->toc_depth++;
   tags = gst_toc_entry_get_tags (entry);
   if (tags)
@@ -1808,13 +1936,18 @@ send_toc_foreach (gpointer data, gpointer user_data)
   g_list_foreach (subentries, send_toc_foreach, ps);
   ps->toc_depth--;
 
-  s = g_strdup_printf ("%*.*s</%s>\n", ps->toc_depth * 2, ps->toc_depth * 2, " 
",
+  s = g_strdup_printf ("%*.*s</%s>\n",
+                       ps->toc_depth * 2,
+                       ps->toc_depth * 2, " ",
                       gst_toc_entry_type_get_nick (entype));
-  if (ps->toc_print_phase)
-    ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - 
ps->toc_pos, "%s", s);
-  else
-    ps->toc_length += strlen (s);
-  g_free (s);
+  if (NULL != s)
+  {
+    if (ps->toc_print_phase)
+      ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - 
ps->toc_pos, "%s", s);
+    else
+      ps->toc_length += strlen (s);
+    g_free (s);
+  }
 }
 
 
@@ -1838,11 +1971,17 @@ send_info (GstDiscovererInfo * info,
   if ((GST_CLOCK_TIME_IS_VALID (duration)) && (duration > 0))
   {
     s = g_strdup_printf ("%" GST_TIME_FORMAT, GST_TIME_ARGS (duration));
-    if (s)
-      ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-          EXTRACTOR_METATYPE_DURATION, EXTRACTOR_METAFORMAT_UTF8, "text/plain",
-          (const char *) s, strlen (s) + 1);
-    g_free (s);
+    if (NULL != s)
+    {
+      ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                        "gstreamer",
+                                        EXTRACTOR_METATYPE_DURATION,
+                                        EXTRACTOR_METAFORMAT_UTF8,
+                                        "text/plain",
+                                        (const char *) s,
+                                        strlen (s) + 1);
+      g_free (s);
+    }
   }
 
   if (ps->time_to_leave)
@@ -1870,21 +2009,25 @@ send_info (GstDiscovererInfo * info,
       ps->toc_print_phase = TRUE;
       ps->toc_length += 1 + strlen (TOC_XML_HEADER);
       ps->toc = g_malloc (ps->toc_length);
-      ps->toc_pos = 0;
-      ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos],
-                                ps->toc_length - ps->toc_pos,
-                                "%s",
-                                TOC_XML_HEADER);
-      g_list_foreach (entries, &send_toc_foreach, ps);
-      ps->toc[ps->toc_length - 1] = '\0';
-      ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
-                                       EXTRACTOR_METATYPE_TOC,
-                                       EXTRACTOR_METAFORMAT_C_STRING,
-                                       "application/xml",
-                                       (const char *) ps->toc,
-                                       ps->toc_length);
-      g_free (ps->toc);
-      ps->toc = NULL;
+      if (NULL != ps->toc)
+      {
+        ps->toc_pos = 0;
+        ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos],
+                                   ps->toc_length - ps->toc_pos,
+                                   "%s",
+                                   TOC_XML_HEADER);
+        g_list_foreach (entries, &send_toc_foreach, ps);
+        ps->toc[ps->toc_length - 1] = '\0';
+        ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+                                          "gstreamer",
+                                          EXTRACTOR_METATYPE_TOC,
+                                          EXTRACTOR_METAFORMAT_C_STRING,
+                                          "application/xml",
+                                          (const char *) ps->toc,
+                                          ps->toc_length);
+        g_free (ps->toc);
+        ps->toc = NULL;
+      }
     }
   }
 
@@ -2079,22 +2222,29 @@ gstreamer_init ()
                          0, "GStreamer-based libextractor plugin");
 
   audio_quarks = g_new0 (GQuark, 4);
-  audio_quarks[0] = g_quark_from_string ("rate");
-  audio_quarks[1] = g_quark_from_string ("channels");
-  audio_quarks[2] = g_quark_from_string ("depth");
-  audio_quarks[3] = g_quark_from_string (NULL);
-
+  if (NULL != audio_quarks)
+    {
+      audio_quarks[0] = g_quark_from_string ("rate");
+      audio_quarks[1] = g_quark_from_string ("channels");
+      audio_quarks[2] = g_quark_from_string ("depth");
+      audio_quarks[3] = g_quark_from_string (NULL);
+    }
   video_quarks = g_new0 (GQuark, 6);
-  video_quarks[0] = g_quark_from_string ("width");
-  video_quarks[1] = g_quark_from_string ("height");
-  video_quarks[2] = g_quark_from_string ("framerate");
-  video_quarks[3] = g_quark_from_string ("max-framerate");
-  video_quarks[4] = g_quark_from_string ("pixel-aspect-ratio");
-  video_quarks[5] = g_quark_from_string (NULL);
-
+  if (NULL != video_quarks)
+    {
+      video_quarks[0] = g_quark_from_string ("width");
+      video_quarks[1] = g_quark_from_string ("height");
+      video_quarks[2] = g_quark_from_string ("framerate");
+      video_quarks[3] = g_quark_from_string ("max-framerate");
+      video_quarks[4] = g_quark_from_string ("pixel-aspect-ratio");
+      video_quarks[5] = g_quark_from_string (NULL);
+    }
   subtitle_quarks = g_new0 (GQuark, 2);
-  subtitle_quarks[0] = g_quark_from_string ("language-code");
-  subtitle_quarks[1] = g_quark_from_string (NULL);
+  if (NULL != subtitle_quarks)
+    {
+      subtitle_quarks[0] = g_quark_from_string ("language-code");
+      subtitle_quarks[1] = g_quark_from_string (NULL);
+    }
 
   duration_quark = g_quark_from_string ("duration");
 
diff --git a/src/plugins/jpeg_extractor.c b/src/plugins/jpeg_extractor.c
index 564da46f..d6c1f6f6 100644
--- a/src/plugins/jpeg_extractor.c
+++ b/src/plugins/jpeg_extractor.c
@@ -162,7 +162,7 @@ EXTRACTOR_jpeg_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
        continue;
       off = 0;
       while ( (off < mptr->data_length) &&
-             (isspace ((int) ((const char *)mptr->data)[mptr->data_length - 1 
- off])) )
+             (isspace (((const unsigned char *)mptr->data)[mptr->data_length - 
1 - off])) )
        off++;
       if (0 !=
          ec->proc (ec->cls,
diff --git a/src/plugins/ogg_extractor.c b/src/plugins/ogg_extractor.c
index 6b7db49f..d7005ef4 100644
--- a/src/plugins/ogg_extractor.c
+++ b/src/plugins/ogg_extractor.c
@@ -75,7 +75,7 @@ read_ogg (void *ptr, size_t size, size_t nmemb, void 
*datasource)
  * @param whence how to seek
  * @return -1 on error, new position on success
  */
-static int 
+static int
 seek_ogg (void *datasource,
          ogg_int64_t offset,
          int whence)
@@ -92,7 +92,7 @@ seek_ogg (void *datasource,
  * Tell ogg where we are in the file
  *
  * @param datasource  the 'struct EXTRACTOR_ExtractContext'
- * @return 
+ * @return
  */
 static long
 tell_ogg (void *datasource)
@@ -114,7 +114,7 @@ tell_ogg (void *datasource)
  * @return NULL on error, otherwise the meta data
  */
 static char *
-get_comment (vorbis_comment *vc, 
+get_comment (vorbis_comment *vc,
             const char *label)
 {
   if (NULL == vc)
@@ -176,7 +176,6 @@ EXTRACTOR_ogg_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
     ov_clear (&vf);
     return;
   }
-  ret = 0;
   ADD (EXTRACTOR_METATYPE_MIMETYPE, "application/ogg");
   if ((comments->vendor != NULL) && (strlen (comments->vendor) > 0))
     ADD (EXTRACTOR_METATYPE_VENDOR, comments->vendor);
@@ -202,4 +201,3 @@ FINISH:
 }
 
 /* end of ogg_extractor.c */
-
diff --git a/src/plugins/ole2_extractor.c b/src/plugins/ole2_extractor.c
index 265120a8..e8e210eb 100644
--- a/src/plugins/ole2_extractor.c
+++ b/src/plugins/ole2_extractor.c
@@ -68,7 +68,7 @@ static int
 add_metadata (EXTRACTOR_MetaDataProcessor proc,
              void *proc_cls,
              const char *phrase,
-             enum EXTRACTOR_MetaType type) 
+             enum EXTRACTOR_MetaType type)
 {
   char *tmp;
   int ret;
@@ -83,11 +83,11 @@ add_metadata (EXTRACTOR_MetaDataProcessor proc,
     return 0;
   if (NULL == (tmp = strdup (phrase)))
     return 0;
-  
+
   while ( (strlen (tmp) > 0) &&
          (isblank ((unsigned char) tmp [strlen (tmp) - 1])) )
     tmp [strlen (tmp) - 1] = '\0';
-  ret = proc (proc_cls, 
+  ret = proc (proc_cls,
              "ole2",
              type,
              EXTRACTOR_METAFORMAT_UTF8,
@@ -103,7 +103,7 @@ add_metadata (EXTRACTOR_MetaDataProcessor proc,
  * Entry in the map from OLE meta type  strings
  * to LE types.
  */
-struct Matches 
+struct Matches
 {
   /**
    * OLE description.
@@ -152,7 +152,7 @@ static struct Matches tmap[] = {
   { "meta:creation-date", EXTRACTOR_METATYPE_CREATION_DATE },
   { "meta:generator", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE },
   { "meta:template", EXTRACTOR_METATYPE_TEMPLATE },
-  { "meta:editing-cycles", EXTRACTOR_METATYPE_EDITING_CYCLES }, 
+  { "meta:editing-cycles", EXTRACTOR_METATYPE_EDITING_CYCLES },
   /* { "Dictionary", EXTRACTOR_METATYPE_LANGUAGE },  */
   /* { "gsf:security", EXTRACTOR_SECURITY }, */
   /* { "gsf:scale", EXTRACTOR_SCALE }, // always "false"? */
@@ -192,10 +192,10 @@ struct ProcContext
  * @param value the UTF8 representation of the meta data
  * @param user_data our 'struct ProcContext' (closure)
  */
-static void 
+static void
 process_metadata (gpointer key,
                  gpointer value,
-                 gpointer user_data) 
+                 gpointer user_data)
 {
   const char *type = key;
   const GsfDocProp *prop = value;
@@ -211,7 +211,7 @@ process_metadata (gpointer key,
     return;
   gval = gsf_doc_prop_get_val (prop);
 
-  if (G_VALUE_TYPE(gval) == G_TYPE_STRING) 
+  if (G_VALUE_TYPE(gval) == G_TYPE_STRING)
     {
       contents = strdup (g_value_get_string (gval));
     }
@@ -241,8 +241,8 @@ process_metadata (gpointer key,
       else if (0 == strncmp(value, "Microsoft Office", 16))
        mimetype = "application/vnd.ms-office";
       if (0 != add_metadata (pc->proc,
-                            pc->proc_cls, 
-                            mimetype, 
+                            pc->proc_cls,
+                            mimetype,
                             EXTRACTOR_METATYPE_MIMETYPE))
        {
          free (contents);
@@ -270,7 +270,7 @@ process_metadata (gpointer key,
 /**
  * Function called on (Document)SummaryInformation OLE
  * streams.
- * 
+ *
  * @param in the input OLE stream
  * @param proc function to call on meta data found
  * @param proc_cls closure for proc
@@ -312,7 +312,7 @@ process (GsfInput *in,
 /**
  * Function called on SfxDocumentInfo OLE
  * streams.
- * 
+ *
  * @param in the input OLE stream
  * @param proc function to call on meta data found
  * @param proc_cls closure for proc
@@ -321,11 +321,11 @@ process (GsfInput *in,
 static int
 process_star_office (GsfInput *src,
                     EXTRACTOR_MetaDataProcessor proc,
-                    void *proc_cls) 
+                    void *proc_cls)
 {
   off_t size = gsf_input_size (src);
 
-  if ( (size < 0x374) || 
+  if ( (size < 0x374) ||
        (size > 4*1024*1024) )  /* == 0x375?? */
     return 0;
   {
@@ -339,7 +339,7 @@ process_star_office (GsfInput *src,
                        strlen ("SfxDocumentInfo"))) ||
         (buf[0x11] != 0x0B) ||
         (buf[0x13] != 0x00) || /* pw protected! */
-        (buf[0x12] != 0x00) ) 
+        (buf[0x12] != 0x00) )
       return 0;
     buf[0xd3] = '\0';
     if ( (buf[0x94] + buf[0x93] > 0) &&
@@ -374,7 +374,7 @@ process_star_office (GsfInput *src,
 
 /**
  * We use "__" to translate using iso-639.
- * 
+ *
  * @param a string to translate
  * @return translated string
  */
@@ -384,11 +384,11 @@ process_star_office (GsfInput *src,
 /**
  * Get the language string for the given language ID (lid)
  * value.
- * 
+ *
  * @param lid language id value
  * @return language string corresponding to the lid
  */
-static const char * 
+static const char *
 lid_to_language (unsigned int lid)
 {
   switch (lid)
@@ -554,7 +554,7 @@ history_extract (GsfInput *stream,
   nRev = (lbuffer[2] + (lbuffer[3] << 8)) / 2;
   where = 6;
   ret = 0;
-  for (i=0; i < nRev; i++) 
+  for (i=0; i < nRev; i++)
     {
       if (where >= lcbSttbSavedBy)
        break;
@@ -568,7 +568,7 @@ history_extract (GsfInput *stream,
       where += length * 2 + 1;
       length = lbuffer[where++];
       if ( (where + 2 * length >= lcbSttbSavedBy) ||
-          (where + 2 * length + 1 <= where) ) 
+          (where + 2 * length + 1 <= where) )
        {
          if (NULL != author)
            free(author);
@@ -581,20 +581,30 @@ history_extract (GsfInput *stream,
       if ( (NULL != author) &&
           (NULL != filename) )
        {
-         if (NULL != (rbuf = malloc (strlen (author) + strlen (filename) + 
512)))
+          size_t bsize;
+
+          bsize = strlen (author) + strlen (filename) + 512;
+          if (NULL != (rbuf = malloc (bsize)))
            {
-             snprintf (rbuf, 
-                       512 + strlen (author) + strlen (filename),
-                       _("Revision #%u: Author `%s' worked on `%s'"),
-                       i,
-                       author,
-                       filename);
-             ret = add_metadata (proc, proc_cls,
-                                 rbuf,
-                                 EXTRACTOR_METATYPE_REVISION_HISTORY);    
+              int snret;
+
+              snret = snprintf (rbuf,
+                                bsize,
+                                _("Revision #%u: Author `%s' worked on `%s'"),
+                                i,
+                                author,
+                                filename);
+              if ( (-1 != snret) &&
+                   (bsize > (size_t) snret) )
+                {
+                  ret = add_metadata (proc,
+                                      proc_cls,
+                                      rbuf,
+                                      EXTRACTOR_METATYPE_REVISION_HISTORY);
+                }
              free (rbuf);
            }
-       }
+        }
       if (NULL != author)
        free (author);
       if (NULL != filename)
@@ -619,7 +629,7 @@ history_extract (GsfInput *stream,
 /**
  * Internal state of an "LeInput" object.
  */
-typedef struct _LeInputPrivate 
+typedef struct _LeInputPrivate
 {
   /**
    * Our extraction context.
@@ -631,13 +641,13 @@ typedef struct _LeInputPrivate
 /**
  * Overall state of an "LeInput" object.
  */
-typedef struct _LeInput 
+typedef struct _LeInput
 {
   /**
    * Inherited state from parent (GsfInput).
    */
   GsfInput input;
-  
+
   /*< private > */
   /**
    * Private state of the LeInput.
@@ -665,7 +675,7 @@ typedef struct _LeInputClass
 
 
 /**
- * Constructor for LeInput objects. 
+ * Constructor for LeInput objects.
  *
  * @param ec extraction context to use
  * @return the LeInput, NULL on error
@@ -737,15 +747,15 @@ le_input_read (GsfInput *input,
   void *buf;
   uint64_t old_off;
   ssize_t ret;
-  
+
   ec = li->priv->ec;
   old_off = ec->seek (ec->cls, 0, SEEK_CUR);
-  if (num_bytes 
+  if (num_bytes
       != (ret = ec->read (ec->cls,
                          &buf,
                          num_bytes)))
     {
-      /* we don't support partial reads; 
+      /* we don't support partial reads;
         most other GsfInput implementations in this case
         allocate some huge temporary buffer just to avoid
         the partial read; we might need to do that as well!? */
@@ -794,7 +804,7 @@ le_input_seek (GsfInput *input,
     default:
       return TRUE;
     }
-  if (-1 == 
+  if (-1 ==
       (ret = ec->seek (ec->cls,
                       offset,
                       w)))
@@ -869,7 +879,7 @@ le_input_new (struct EXTRACTOR_ExtractContext *ec)
 
 
 /**
- * Main entry method for the OLE2 extraction plugin.  
+ * Main entry method for the OLE2 extraction plugin.
  *
  * @param ec extraction context provided to the plugin
  */
@@ -933,7 +943,7 @@ EXTRACTOR_ole2_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
       return;
     }
   ret = 0;
-  for (i=0;i<gsf_infile_num_children (infile);i++) 
+  for (i=0;i<gsf_infile_num_children (infile);i++)
     {
       if (0 != ret)
        break;
@@ -944,7 +954,7 @@ EXTRACTOR_ole2_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
             (0 == strcmp (name, "\005DocumentSummaryInformation")) ) &&
           (NULL != (src = gsf_infile_child_by_index (infile, i))) )
        ret = process (src,
-                      ec->proc, 
+                      ec->proc,
                       ec->cls);
       if ( (0 == strcmp (name, "SfxDocumentInfo")) &&
           (NULL != (src = gsf_infile_child_by_index (infile, i))) )
@@ -959,7 +969,7 @@ EXTRACTOR_ole2_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
 
   if (lcb < 6)
     goto CLEANUP;
-  for (i=0;i<gsf_infile_num_children (infile);i++) 
+  for (i=0;i<gsf_infile_num_children (infile);i++)
     {
       if (ret != 0)
        break;
@@ -974,7 +984,7 @@ EXTRACTOR_ole2_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
                                 fcb,
                                 ec->proc, ec->cls);
          g_object_unref (G_OBJECT (src));
-       }    
+       }
     }
  CLEANUP:
   g_object_unref (G_OBJECT (infile));
@@ -990,11 +1000,11 @@ EXTRACTOR_ole2_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
  * @param message unused
  * @param user_data unused
  */
-static void 
+static void
 nolog (const gchar *log_domain,
        GLogLevelFlags log_level,
        const gchar *message,
-       gpointer user_data) 
+       gpointer user_data)
 {
   /* do nothing */
 }
@@ -1004,8 +1014,8 @@ nolog (const gchar *log_domain,
  * OLE2 plugin constructor. Initializes glib and gsf, in particular
  * gsf logging is disabled.
  */
-void __attribute__ ((constructor)) 
-ole2_ltdl_init() 
+void __attribute__ ((constructor))
+ole2_ltdl_init()
 {
 #if !GLIB_CHECK_VERSION(2, 35, 0)
   g_type_init ();
@@ -1015,7 +1025,7 @@ ole2_ltdl_init()
 #endif
   /* disable logging -- thanks, Jody! */
   g_log_set_handler ("libgsf:msole",
-                    G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,  
+                    G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
                     &nolog, NULL);
 }
 
@@ -1024,7 +1034,7 @@ ole2_ltdl_init()
  * OLE2 plugin destructor.  Shutdown of gsf.
  */
 void __attribute__ ((destructor))
-ole2_ltdl_fini() 
+ole2_ltdl_fini()
 {
 #ifdef HAVE_GSF_INIT
   gsf_shutdown();
diff --git a/src/plugins/pdf_extractor.c b/src/plugins/pdf_extractor.c
index b84981fa..da1f6636 100644
--- a/src/plugins/pdf_extractor.c
+++ b/src/plugins/pdf_extractor.c
@@ -100,7 +100,7 @@ process_stdout (FILE *fout,
       if (NULL == colon)
         break;
       psuffix = colon + 1;
-      while (isblank ((int) psuffix[0]))
+      while (isblank ((unsigned char) psuffix[0]))
         psuffix++;
       if (0 == strlen (psuffix))
         continue;
@@ -178,8 +178,9 @@ EXTRACTOR_pdf_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
       /* am child, exec 'pdfinfo' */
       close (0);
       close (1);
-      dup2 (in[0], 0);
-      dup2 (out[1], 1);
+      if ( (-1 == dup2 (in[0], 0)) ||
+           (-1 == dup2 (out[1], 1)) )
+        exit (1);
       close (in[0]);
       close (in[1]);
       close (out[0]);
@@ -191,7 +192,14 @@ EXTRACTOR_pdf_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
   close (in[0]);
   close (out[1]);
   fout = fdopen (out[0], "r");
-
+  if (NULL == fout)
+    {
+      close (in[1]);
+      close (out[0]);
+      kill (pid, SIGKILL);
+      waitpid (pid, NULL, 0);
+      return;
+    }
   pos = 0;
   while (pos < fsize)
     {
diff --git a/src/plugins/ps_extractor.c b/src/plugins/ps_extractor.c
index 41776bb2..3a7f26da 100644
--- a/src/plugins/ps_extractor.c
+++ b/src/plugins/ps_extractor.c
@@ -49,7 +49,7 @@ struct Matches
    * PS header prefix.
    */
   const char *prefix;
-  
+
   /**
    * Corresponding LE type.
    */
@@ -106,7 +106,7 @@ readline (struct EXTRACTOR_ExtractContext *ec)
 
   pos = ec->seek (ec->cls, 0, SEEK_CUR);
   if (0 >= (ret = ec->read (ec->cls, &data, MAX_LINE)))
-    return NULL; 
+    return NULL;
   cdata = data;
   if (NULL == (eol = memchr (cdata, '\n', ret)))
     return NULL; /* no end-of-line found */
@@ -120,7 +120,7 @@ readline (struct EXTRACTOR_ExtractContext *ec)
 
 
 /**
- * Main entry method for the 'application/postscript' extraction plugin.  
+ * Main entry method for the 'application/postscript' extraction plugin.
  *
  * @param ec extraction context provided to the plugin
  */
@@ -152,7 +152,7 @@ EXTRACTOR_ps_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
                     "application/postscript",
                     strlen ("application/postscript") + 1))
     return;
-  
+
   line = NULL;
   next = readline (ec);
   while ( (NULL != next) &&
@@ -170,8 +170,8 @@ EXTRACTOR_ps_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
          while ( (NULL != next) &&
                  (0 == strncmp (next, "%%+", strlen ("%%+"))) )
            {
-             if (NULL == (acc = malloc (strlen (line) + strlen (next) - 1)))   
        
-               break;                        
+             if (NULL == (acc = malloc (strlen (line) + strlen (next) - 1)))
+               break;
              strcpy (acc, line);
              strcat (acc, " ");
              strcat (acc, next + 3);
@@ -180,7 +180,7 @@ EXTRACTOR_ps_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
              free (next);
              next = readline (ec);
            }
-         if ( (line[strlen (line) - 1] == ')') && 
+         if ( (line[strlen (line) - 1] == ')') &&
               (line[strlen (match)] == '(') )
            {
              acc = &line[strlen (match) + 1];
@@ -190,7 +190,7 @@ EXTRACTOR_ps_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
            {
              acc = &line[strlen (match)];
            }
-         while (isspace ((unsigned int) acc[0]))
+         while (isspace ((unsigned char) acc[0]))
            acc++;
          if ( (strlen (acc) > 0) &&
               (0 != ec->proc (ec->cls,
diff --git a/src/plugins/rpm_extractor.c b/src/plugins/rpm_extractor.c
index d54e3417..21596d25 100644
--- a/src/plugins/rpm_extractor.c
+++ b/src/plugins/rpm_extractor.c
@@ -348,12 +348,15 @@ EXTRACTOR_rpm_extract_method (struct 
EXTRACTOR_ExtractContext *ec)
            {
              if (p->tag == RPMTAG_BUILDTIME)
                {
-                 char tmp[30];
+                 char tmp[80];
                  uint32_t *v = rpmtdNextUint32 (p);
                  time_t tp = (time_t) *v;
 
-                 ctime_r (&tp, tmp);
-                 tmp[strlen (tmp) - 1] = '\0';   /* eat linefeed */
+                  if (NULL == ctime_r (&tp, tmp))
+                    break;
+                  if ( (strlen (tmp) > 0) &&
+                       (isspace ((unsigned char) tmp[strlen(tmp)-1])) )
+                    tmp[strlen (tmp) - 1] = '\0';   /* eat linefeed */
                  pthread_mutex_lock (&parg.lock);
                  if (0 != ec->proc (ec->cls,
                                     "rpm",
diff --git a/src/plugins/thumbnailffmpeg_extractor.c 
b/src/plugins/thumbnailffmpeg_extractor.c
index 0619efd1..c2af2409 100644
--- a/src/plugins/thumbnailffmpeg_extractor.c
+++ b/src/plugins/thumbnailffmpeg_extractor.c
@@ -621,6 +621,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
   int err;
   int frame_finished;
   unsigned char *iob;
+  int duration;
 
   if (NULL == (iob = av_malloc (16 * 1024)))
     return;
@@ -704,32 +705,27 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
       av_free (io_ctx);
       return;
     }
-  int duration;
+
   if (format_ctx->duration == AV_NOPTS_VALUE)
-       {
-       duration = -1;
+    {
+      duration = -1;
 #if DEBUG
-    fprintf (stderr,
-            "Duration unknown\n");
+      fprintf (stderr,
+               "Duration unknown\n");
 #endif
-       }
+    }
   else
-  {
-#if DEBUG
-       duration = format_ctx->duration;
-    fprintf (stderr,
-            "Duration: %lld\n",
-            format_ctx->duration);
-#endif
-       }
+    {
+      duration = format_ctx->duration;
+    }
 
   /* if duration is known, seek to first tried,
    * else use 10 sec into stream */
 
   if(-1 != duration)
-       err = av_seek_frame (format_ctx, -1, (duration/3), 0);
+    err = av_seek_frame (format_ctx, -1, (duration/3), 0);
   else
-       err = av_seek_frame (format_ctx, -1, 10 * AV_TIME_BASE, 0);
+    err = av_seek_frame (format_ctx, -1, 10 * AV_TIME_BASE, 0);
 
   if (err >= 0)
     avcodec_flush_buffers (codec_ctx);

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



reply via email to

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