Submitted by: Jim Gifford (jim at cross-lfs dot org) Date: 2009-03-01 Initial Package Version: 5.00 Upstream Status: Already Applied Origin: Jim Gifford Description: Fixes Various Build Issues in File Localization Fixes diff -Naur file-5.00.orig/magic/Magdir/msdos file-5.00/magic/Magdir/msdos --- file-5.00.orig/magic/Magdir/msdos 2008-12-12 13:04:45.000000000 -0800 +++ file-5.00/magic/Magdir/msdos 2009-03-01 23:24:12.209606649 -0800 @@ -294,22 +294,37 @@ >10 string >\x23 >>10 string !\x2e >>>17 string <\x5B ->>>>10 string x \b, name: %.8s -#UDMA.SYS KEYB.SYS CMD640X2.SYS +>>>>10 string CMD640X2.SYS \b, name: %.8s +#UDMA.SYS >10 string <\x41 >>12 string >\x40 >>>10 string !$ ->>>>12 string x \b, name: %.8s -#BTCDROM.SYS ASPICD.SYS +>>>>12 string UDMA.SYS \b, name: %.8s +#CMD640X2.SYS +>10 string <\x41 +>>12 string >\x40 +>>>10 string !$ +>>>>12 string CMD640X2.SYS \b, name: %.8s +#KEYB.SYS +>10 string <\x41 +>>12 string >\x40 +>>>10 string !$ +>>>>12 string KEYB.SYS \b, name: %.8s +#BTCDROM.SYS +>22 string >\x40 +>>22 string <\x5B +>>>23 string <\x5B +>>>>22 string BTCDROM.SYS \b, name: %.8s +#ASPICD.SYS >22 string >\x40 >>22 string <\x5B >>>23 string <\x5B ->>>>22 string x \b, name: %.8s +>>>>22 string ASPICD.SYS \b, name: %.8s #ATAPICD.SYS >76 string \0 >>77 string >\x40 >>>77 string <\x5B ->>>>77 string x \b, name: %.8s +>>>>77 string ATAPICD.SYS \b, name: %.8s # test too generic ? 0 byte 0x8c DOS executable (COM) # updated by Joerg Jenderek at Oct 2008 diff -Naur file-5.00.orig/src/cdf.c file-5.00/src/cdf.c --- file-5.00.orig/src/cdf.c 2009-02-03 12:27:51.000000000 -0800 +++ file-5.00/src/cdf.c 2009-03-01 23:26:11.953279788 -0800 @@ -239,7 +239,9 @@ cdf_unpack_header(h, buf); cdf_swap_header(h); if (h->h_magic != CDF_MAGIC) { - DPRINTF(("Bad magic 0x%x != 0x$x\n", h->h_magic, CDF_MAGIC)); + DPRINTF(("Bad magic 0x%llx != 0x%llx\n", + (unsigned long long)h->h_magic, + (unsigned long long)CDF_MAGIC)); errno = EFTYPE; return -1; } @@ -539,10 +541,11 @@ if (dir->dir_tab[i].d_type == CDF_DIR_TYPE_ROOT_STORAGE) break; + /* If the it is not there, just fake it; some docs don't have it */ if (i == dir->dir_len) { - DPRINTF(("Cannot find root storage node\n")); - errno = EFTYPE; - return -1; + scn->sst_tab = NULL; + scn->sst_len = 0; + return 0; } d = &dir->dir_tab[i]; diff -Naur file-5.00.orig/src/readcdf.c file-5.00/src/readcdf.c --- file-5.00.orig/src/readcdf.c 2009-02-03 12:27:51.000000000 -0800 +++ file-5.00/src/readcdf.c 2009-03-01 23:26:11.953279788 -0800 @@ -75,9 +75,23 @@ if (len > 1) { s = info[i].pi_str.s_buf; if (NOTMIME(ms)) { - if (file_printf(ms, ", %s: %.*s", buf, - len, s) == -1) - return -1; + char vbuf[1024]; + size_t j; + for (j = 0; j < sizeof(vbuf) && len--; + j++, s++) { + if (*s == '\0') + break; + if (isprint((unsigned char)*s)) + vbuf[j] = *s; + } + if (j == sizeof(vbuf)) + --j; + vbuf[j] = '\0'; + if (vbuf[0]) { + if (file_printf(ms, ", %s: %s", + buf, vbuf) == -1) + return -1; + } } else if (info[i].pi_id == CDF_PROPERTY_NAME_OF_APPLICATION) { if (strstr(s, "Word")) @@ -115,7 +129,10 @@ case CDF_CLIPBOARD: break; default: - file_error(ms, 0, "Internal parsing error"); +#ifndef EFTYPE /* XXX: vapier: copied from cdf.c for now ... */ +#define EFTYPE EINVAL +#endif + errno = EFTYPE; return -1; } } @@ -188,6 +205,7 @@ cdf_stream_t sst, scn; cdf_dir_t dir; int i; + const char *expn = ""; (void)&nbytes; (void)&buf; @@ -200,7 +218,7 @@ #endif if (cdf_read_sat(fd, &h, &sat) == -1) { - file_error(ms, errno, "Can't read SAT"); + expn = "Can't read SAT"; return -1; } #ifdef CDF_DEBUG @@ -208,7 +226,7 @@ #endif if ((i = cdf_read_ssat(fd, &h, &sat, &ssat)) == -1) { - file_error(ms, errno, "Can't read SAT"); + expn = "Can't read SSAT"; goto out1; } #ifdef CDF_DEBUG @@ -216,12 +234,12 @@ #endif if ((i = cdf_read_dir(fd, &h, &sat, &dir)) == -1) { - file_error(ms, errno, "Can't read directory"); + expn = "Can't read directory"; goto out2; } if ((i = cdf_read_short_stream(fd, &h, &sat, &dir, &sst)) == -1) { - file_error(ms, errno, "Cannot read short stream"); + expn = "Cannot read short stream"; goto out3; } @@ -230,19 +248,14 @@ #endif if ((i = cdf_read_summary_info(fd, &h, &sat, &ssat, &sst, &dir, &scn)) == -1) { - /* Some files don't have summary info! */ -#ifdef notyet - file_error(ms, errno, "Can't read summary_info"); -#else - i = 0; -#endif + expn = ""; goto out4; } #ifdef CDF_DEBUG cdf_dump_summary_info(&h, &scn); #endif if ((i = cdf_file_summary_info(ms, &scn)) == -1) - file_error(ms, errno, "Can't expand summary_info"); + expn = "Can't expand summary_info"; free(scn.sst_tab); out4: free(sst.sst_tab); @@ -252,5 +265,13 @@ free(ssat.sat_tab); out1: free(sat.sat_tab); + if (i != 1) { + if (file_printf(ms, "CDF V2 Document") == -1) + return -1; + if (*expn) + if (file_printf(ms, ", corrupt: %s", expn) == -1) + return -1; + i = 1; + } return i; }