summaryrefslogtreecommitdiff
path: root/src/lfn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lfn.c')
-rw-r--r--src/lfn.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/lfn.c b/src/lfn.c
index 2601172..b33e125 100644
--- a/src/lfn.c
+++ b/src/lfn.c
@@ -2,6 +2,7 @@
Copyright (C) 1998 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
Copyright (C) 2008-2014 Daniel Baumann <mail@daniel-baumann.ch>
+ Copyright (C) 2015 Andreas Bombe <aeb@debian.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -53,7 +54,7 @@ typedef struct {
unsigned char *lfn_unicode = NULL;
unsigned char lfn_checksum;
int lfn_slot = -1;
-loff_t *lfn_offsets = NULL;
+off_t *lfn_offsets = NULL;
int lfn_parts = 0;
static unsigned char fat_uni2esc[64] = {
@@ -171,7 +172,7 @@ static void clear_lfn_slots(int start, int end)
}
}
-void lfn_fix_checksum(loff_t from, loff_t to, const char *short_name)
+void lfn_fix_checksum(off_t from, off_t to, const char *short_name)
{
int i;
uint8_t sum;
@@ -196,7 +197,7 @@ void lfn_reset(void)
/* This function is only called with de->attr == VFAT_LN_ATTR. It stores part
* of the long name. */
-void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
+void lfn_add_slot(DIR_ENT * de, off_t dir_offset)
{
LFN_ENT *lfn = (LFN_ENT *) de;
int slot = lfn->id & LFN_ID_SLOTMASK;
@@ -254,7 +255,7 @@ void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
lfn_slot = slot;
lfn_checksum = lfn->alias_checksum;
lfn_unicode = alloc((lfn_slot * CHARS_PER_LFN + 1) * 2);
- lfn_offsets = alloc(lfn_slot * sizeof(loff_t));
+ lfn_offsets = alloc(lfn_slot * sizeof(off_t));
lfn_parts = 0;
} else if (lfn_slot == -1 && slot != 0) {
/* No LFN in progress, but slot found; start bit missing */
@@ -265,6 +266,7 @@ void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
printf("Long filename fragment \"%s\" found outside a LFN "
"sequence.\n (Maybe the start bit is missing on the "
"last fragment)\n", part);
+ free(part);
if (interactive) {
printf("1: Delete fragment\n2: Leave it as it is.\n"
"3: Set start bit\n");
@@ -273,7 +275,7 @@ void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
switch (interactive ? get_key("123", "?") : '2') {
case '1':
if (!lfn_offsets)
- lfn_offsets = alloc(sizeof(loff_t));
+ lfn_offsets = alloc(sizeof(off_t));
lfn_offsets[0] = dir_offset;
clear_lfn_slots(0, 0);
lfn_reset();
@@ -288,7 +290,7 @@ void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
lfn_slot = slot;
lfn_checksum = lfn->alias_checksum;
lfn_unicode = alloc((lfn_slot * CHARS_PER_LFN + 1) * 2);
- lfn_offsets = alloc(lfn_slot * sizeof(loff_t));
+ lfn_offsets = alloc(lfn_slot * sizeof(off_t));
lfn_parts = 0;
break;
}
@@ -320,7 +322,7 @@ void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
switch (interactive ? get_key(can_fix ? "123" : "12", "?") : '2') {
case '1':
if (!lfn_offsets) {
- lfn_offsets = alloc(sizeof(loff_t));
+ lfn_offsets = alloc(sizeof(off_t));
lfn_parts = 0;
}
lfn_offsets[lfn_parts++] = dir_offset;
@@ -407,7 +409,7 @@ void lfn_add_slot(DIR_ENT * de, loff_t dir_offset)
/* This function is always called when de->attr != VFAT_LN_ATTR is found, to
* retrieve the previously constructed LFN. */
-char *lfn_get(DIR_ENT * de, loff_t * lfn_offset)
+char *lfn_get(DIR_ENT * de, off_t * lfn_offset)
{
char *lfn;
uint8_t sum;
@@ -464,10 +466,8 @@ char *lfn_get(DIR_ENT * de, loff_t * lfn_offset)
}
}
- for (sum = 0, i = 0; i < 8; i++)
+ for (sum = 0, i = 0; i < MSDOS_NAME; i++)
sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + de->name[i];
- for (i = 0; i < 3; i++)
- sum = (((sum & 1) << 7) | ((sum & 0xfe) >> 1)) + de->ext[i];
if (sum != lfn_checksum) {
/* checksum doesn't match, long name doesn't apply to this alias */
/* Causes: 1) alias renamed */
@@ -517,6 +517,7 @@ void lfn_check_orphaned(void)
long_name = CNV_PARTS_SO_FAR();
printf("Orphaned long file name part \"%s\"\n", long_name);
+ free(long_name);
if (interactive)
printf("1: Delete.\n2: Leave it.\n");
else