2
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
2
Copyright (c) 1990-2008 Info-ZIP. All rights reserved.
4
4
See the accompanying file LICENSE, version 2000-Apr-09 or later
5
5
(the contents of which are also included in unzip.h) for terms of use.
274
276
G.pInfo->file_attr = (unsigned)(tmp >> 16);
275
if (G.pInfo->file_attr != 0 || !G.extra_field) {
277
if (G.pInfo->file_attr == 0 && G.extra_field) {
278
278
/* Some (non-Info-ZIP) implementations of Zip for Unix and
279
279
* VMS (and probably others ??) leave 0 in the upper 16-bit
280
280
* part of the external_file_attributes field. Instead, they
320
319
ef_len -= (ebLen + EB_HEADSIZE);
321
320
ef += (ebLen + EB_HEADSIZE);
325
/* Check if the file is a (POSIX-compatible) symbolic link.
326
* We restrict symlink support to those "made-by" hosts that
327
* are known to support symbolic links.
329
G.pInfo->symlink = S_ISLNK(G.pInfo->file_attr) &&
330
SYMLINK_HOST(G.pInfo->hostnum);
326
334
/* fall through! */
327
335
/* all remaining cases: expand MSDOS read-only bit into write perms */
351
359
/* read-only bit --> write perms; subdir bit --> dir exec bit */
352
360
tmp = !(tmp & 1) << 1 | (tmp & 0x10) >> 4;
353
if ((G.pInfo->file_attr & 0700) == (unsigned)(0400 | tmp<<6))
361
if ((G.pInfo->file_attr & 0700) == (unsigned)(0400 | tmp<<6)) {
354
362
/* keep previous G.pInfo->file_attr setting, when its "owner"
355
363
* part appears to be consistent with DOS attribute flags!
366
/* Entries "made by FS_FAT_" could have been zipped on a
367
* system that supports POSIX-style symbolic links.
369
G.pInfo->symlink = S_ISLNK(G.pInfo->file_attr) &&
370
(G.pInfo->hostnum == FS_FAT_);
358
374
G.pInfo->file_attr = (unsigned)(0444 | tmp<<6 | tmp<<3 | tmp);
360
376
} /* end switch (host-OS-created-by) */
537
553
*lastsemi = '\0';
556
/* On UNIX (and compatible systems), "." and ".." are reserved for
557
* directory navigation and cannot be used as regular file names.
558
* These reserved one-dot and two-dot names are mapped to "_" and "__".
560
if (strcmp(pathcomp, ".") == 0)
562
else if (strcmp(pathcomp, "..") == 0)
563
strcpy(pathcomp, "__");
540
565
#ifdef ACORN_FTYPE_NFS
541
566
/* translate Acorn filetype information if asked to do so */
542
567
if (uO.acorn_nfs_ext &&
836
static int get_extattribs OF((__GPRO__ iztimes *pzt, ush z_uidgid[2]));
861
static int get_extattribs OF((__GPRO__ iztimes *pzt, ulg z_uidgid[2]));
838
863
static int get_extattribs(__G__ pzt, z_uidgid)
843
868
/*---------------------------------------------------------------------------
844
869
Convert from MSDOS-format local time and date to Unix-format 32-bit GMT
899
924
iztimes t3; /* mtime, atime, ctime */
900
925
struct utimbuf t2; /* modtime, actime */
903
928
int have_uidgid_flg;
907
930
/*---------------------------------------------------------------------------
908
931
If symbolic links are supported, allocate storage for a symlink control
909
932
structure, put the uncompressed "data" and other required info in it, and
932
slnk_entrysize = sizeof(slinkentry) + AtheOSef_len + ucsize +
955
/* size of the symlink entry is the sum of
956
* (struct size (includes 1st '\0') + 1 additional trailing '\0'),
957
* system specific attribute data size (might be 0),
958
* and the lengths of name and link target.
960
slnk_entrysize = (sizeof(slinkentry) + 1) + AtheOSef_len +
961
ucsize + strlen(G.filename);
935
if ((unsigned)slnk_entrysize < ucsize) {
963
if (slnk_entrysize < ucsize) {
936
964
Info(slide, 0x201, ((char *)slide,
937
965
"warning: symbolic link (%s) failed: mem alloc overflow\n",
938
966
FnFilter1(G.filename)));
955
985
/* AtheOS_exfld should not be NULL because AtheOSef_len > 0 */
956
986
memcpy(slnk_entry->buf, AtheOS_exfld, AtheOSef_len);
958
/* reopen the "link data" file for reading */
959
G.outfile = fopen(G.filename, FOPR);
988
/* move back to the start of the file to re-read the "link data" */
962
fread(slnk_entry->target, 1, ucsize, G.outfile) != (int)ucsize)
991
if (fread(slnk_entry->target, 1, ucsize, G.outfile) != ucsize)
964
993
Info(slide, 0x201, ((char *)slide,
965
994
"warning: symbolic link (%s) failed\n",
1004
1035
Info(slide, 0x201, ((char *)slide,
1005
"warning: cannot set UID %d and/or GID %d for %s\n",
1036
"warning: cannot set UID %lu and/or GID %lu for %s\n",
1006
1037
z_uidgid[0], z_uidgid[1], FnFilter1(G.filename)));
1008
1039
Info(slide, 0x201, ((char *)slide,
1009
" (warning) cannot set UID %d and/or GID %d",
1040
" (warning) cannot set UID %lu and/or GID %lu",
1010
1041
z_uidgid[0], z_uidgid[1]));
1014
/* set the file's access and modification times */
1015
if (utime(G.filename, &(zt.t2))) {
1017
Info(slide, 0x201, ((char *)slide,
1018
"warning: cannot set times for %s\n", FnFilter1(G.filename)));
1020
Info(slide, 0x201, ((char *)slide,
1021
" (warning) cannot set times"));
1045
/* skip restoring time stamps on user's request */
1046
if (uO.D_flag <= 1) {
1047
/* set the file's access and modification times */
1048
if (utime(G.filename, &(zt.t2))) {
1050
Info(slide, 0x201, ((char *)slide,
1051
"warning: cannot set times for %s\n",
1052
FnFilter1(G.filename)));
1054
Info(slide, 0x201, ((char *)slide,
1055
" (warning) cannot set times"));
1024
1059
/*---------------------------------------------------------------------------
1054
1089
#ifdef SET_DIR_ATTRIB
1055
1090
/* messages of code for setting directory attributes */
1056
1091
static ZCONST char Far DirlistUidGidFailed[] =
1057
"warning: cannot set UID %d and/or GID %d for %s\n";
1092
"warning: cannot set UID %lu and/or GID %lu for %s\n";
1058
1093
static ZCONST char Far DirlistUtimeFailed[] =
1059
1094
"warning: cannot set modification, access times for %s\n";
1060
1095
# ifndef NO_CHMOD
1102
1137
errval = PK_WARN;
1104
if (utime(d->fn, &UxAtt(d)->u.t2)) {
1105
Info(slide, 0x201, ((char *)slide,
1106
LoadFarString(DirlistUtimeFailed), FnFilter1(d->fn)));
1139
/* Skip restoring directory time stamps on user' request. */
1140
if (uO.D_flag <= 0) {
1141
/* restore directory timestamps */
1142
if (utime(d->fn, &UxAtt(d)->u.t2)) {
1143
Info(slide, 0x201, ((char *)slide,
1144
LoadFarString(DirlistUtimeFailed), FnFilter1(d->fn)));
1110
1149
#ifndef NO_CHMOD
1111
1150
if (chmod(d->fn, filtattr(__G__ UxAtt(d)->perms))) {