Permalink
Browse files

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.
  • Loading branch information...
jedwing committed May 28, 2009
1 parent fec7417 commit 9b479b4f3bbb08e8ab340d6ad626f3549b51d929
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/extract_chmLib.c
View
@@ -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;

0 comments on commit 9b479b4

Please sign in to comment.