Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > 8b1b6ff10503b81fcd1c165282a33fc9 > files > 2

chmlib-0.40-11.mga5.src.rpm

From 9b479b4f3bbb08e8ab340d6ad626f3549b51d929 Mon Sep 17 00:00:00 2001
From: Jed Wing <jed.wing@gmail.com>
Date: Wed, 27 May 2009 18:41:10 -0700
Subject: [PATCH] Fix for extract_chmLib confusing empty files with
 directories.

Patch from Paul Wise <pabs@debian.org> via Kartik Mistry, the maintainer of the
Debian chmlib package.
---
 src/extract_chmLib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/extract_chmLib.c b/src/extract_chmLib.c
index 078cc35..478c892 100644
--- a/src/extract_chmLib.c
+++ b/src/extract_chmLib.c
@@ -102,6 +102,7 @@ int _extract_callback(struct chmFile *h,
               struct chmUnitInfo *ui,
               void *context)
 {
+    LONGUINT64 ui_path_len;
     char buffer[32768];
     struct extract_context *ctx = (struct extract_context *)context;
     char *i;
@@ -119,7 +120,11 @@ int _extract_callback(struct chmFile *h,
     if (snprintf(buffer, sizeof(buffer), "%s%s", ctx->base_path, ui->path) > 1024)
         return CHM_ENUMERATOR_FAILURE;
 
-    if (ui->length != 0)
+    /* Get the length of the path */
+    ui_path_len = strlen(ui->path)-1;
+
+    /* Distinguish between files and dirs */
+    if (ui->path[ui_path_len] != '/' )
     {
         FILE *fout;
         LONGINT64 len, remain=ui->length;
-- 
1.8.4