Skip to content

Commit 9b479b4

Browse files
committed
Fix for extract_chmLib confusing empty files with directories.
Patch from Paul Wise <[email protected]> via Kartik Mistry, the maintainer of the Debian chmlib package.
1 parent fec7417 commit 9b479b4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/extract_chmLib.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ int _extract_callback(struct chmFile *h,
102102
struct chmUnitInfo *ui,
103103
void *context)
104104
{
105+
LONGUINT64 ui_path_len;
105106
char buffer[32768];
106107
struct extract_context *ctx = (struct extract_context *)context;
107108
char *i;
@@ -119,7 +120,11 @@ int _extract_callback(struct chmFile *h,
119120
if (snprintf(buffer, sizeof(buffer), "%s%s", ctx->base_path, ui->path) > 1024)
120121
return CHM_ENUMERATOR_FAILURE;
121122

122-
if (ui->length != 0)
123+
/* Get the length of the path */
124+
ui_path_len = strlen(ui->path)-1;
125+
126+
/* Distinguish between files and dirs */
127+
if (ui->path[ui_path_len] != '/' )
123128
{
124129
FILE *fout;
125130
LONGINT64 len, remain=ui->length;

0 commit comments

Comments
 (0)