Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/netware/netware.c view on Meta::CPAN
if (strcmp(pathcomp, ".") == 0) {
/* don't bother appending "./" to the path */
*pathcomp = '\0';
} else if (!uO.ddotflag && strcmp(pathcomp, "..") == 0) {
/* "../" dir traversal detected, skip over it */
*pathcomp = '\0';
killed_ddot = TRUE; /* set "show message" flag */
}
/* when path component is not empty, append it now */
if (*pathcomp != '\0' &&
((error = checkdir(__G__ pathcomp, APPEND_DIR))
& MPN_MASK) > MPN_INF_TRUNC)
return error;
pp = pathcomp; /* reset conversion buffer for next piece */
lastsemi = (char *)NULL; /* leave direct. semi-colons alone */
break;
case ';': /* VMS version (or DEC-20 attrib?) */
lastsemi = pp;
*pp++ = ';'; /* keep for now; remove VMS ";##" */
break; /* later, if requested */
#ifdef ACORN_FTYPE_NFS
case ',': /* NFS filetype extension */
lastcomma = pp;
*pp++ = ','; /* keep for now; may need to remove */
break; /* later, if requested */
#endif
default:
/* allow European characters in filenames: */
if (isprint(workch) || (128 <= workch && workch <= 254))
*pp++ = (char)workch;
} /* end switch */
} /* end while loop */
/* Show warning when stripping insecure "parent dir" path components */
if (killed_ddot && QCOND2) {
Info(slide, 0, ((char *)slide,
"warning: skipped \"../\" path component(s) in %s\n",
FnFilter1(G.filename)));
if (!(error & ~MPN_MASK))
error = (error & MPN_MASK) | PK_WARN;
}
/*---------------------------------------------------------------------------
Report if directory was created (and no file to create: filename ended
in '/'), check name to be sure it exists, and combine path and name be-
fore exiting.
---------------------------------------------------------------------------*/
if (G.filename[strlen(G.filename) - 1] == '/') {
checkdir(__G__ G.filename, GETPATH);
if (created_dir) {
if (QCOND2) {
Info(slide, 0, ((char *)slide, " creating: %s\n",
FnFilter1(G.filename)));
}
#if !defined(NO_CHMOD) && !defined(NLM)
/* In NetWare, chmod does not work on directories */
/* set approx. dir perms (make sure can still read/write in dir) */
if (chmod(G.filename, (0xffff & G.pInfo->file_attr) | 0700))
perror("chmod (directory attributes) error");
#endif
/* set dir time (note trailing '/') */
return (error & ~MPN_MASK) | MPN_CREATED_DIR;
}
/* dir existed already; don't look for data to extract */
return (error & ~MPN_MASK) | MPN_INF_SKIP;
}
*pp = '\0'; /* done with pathcomp: terminate it */
/* if not saving them, remove VMS version numbers (appended ";###") */
if (!uO.V_flag && lastsemi) {
pp = lastsemi + 1;
while (isdigit((uch)(*pp)))
++pp;
if (*pp == '\0') /* only digits between ';' and end: nuke */
*lastsemi = '\0';
}
#ifdef ACORN_FTYPE_NFS
/* translate Acorn filetype information if asked to do so */
if (uO.acorn_nfs_ext &&
(ef_spark = (RO_extra_block *)
getRISCOSexfield(G.extra_field, G.lrec.extra_field_length))
!= (RO_extra_block *)NULL)
{
/* file *must* have a RISC OS extra field */
long ft = (long)makelong(ef_spark->loadaddr);
/*32-bit*/
if (lastcomma) {
pp = lastcomma + 1;
while (isxdigit((uch)(*pp))) ++pp;
if (pp == lastcomma+4 && *pp == '\0') *lastcomma='\0'; /* nuke */
}
if ((ft & 1<<31)==0) ft=0x000FFD00;
sprintf(pathcomp+strlen(pathcomp), ",%03x", (int)(ft>>8) & 0xFFF);
}
#endif /* ACORN_FTYPE_NFS */
if (*pathcomp == '\0') {
Info(slide, 1, ((char *)slide, "mapname: conversion of %s failed\n",
FnFilter1(G.filename)));
return (error & ~MPN_MASK) | MPN_ERR_SKIP;
}
checkdir(__G__ pathcomp, APPEND_NAME); /* returns 1 if truncated: care? */
checkdir(__G__ G.filename, GETPATH);
return error;
} /* end function mapname() */
/***********************/
/* Function checkdir() */
/***********************/
int checkdir(__G__ pathcomp, flag)
unzip-6.0/netware/netware.c view on Meta::CPAN
}
#endif /* !SFX || SFX_EXDIR */
/*---------------------------------------------------------------------------
END: free rootpath, immediately prior to program exit.
---------------------------------------------------------------------------*/
if (FUNCTION == END) {
Trace((stderr, "freeing rootpath\n"));
if (rootlen > 0) {
free(rootpath);
rootlen = 0;
}
return MPN_OK;
}
return MPN_INVALID; /* should never reach */
} /* end function checkdir() */
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G) /* GRR: change to return PK-style warning level */
__GDEF
{
fclose(G.outfile);
/* skip restoring time stamps on user's request */
if (uO.D_flag <= 1) {
WORD date = G.lrec.last_mod_dos_datetime >> 16;
WORD time = G.lrec.last_mod_dos_datetime & 0xffff;
static struct ModifyStructure changeBuffer;
/* set the file's access and modification times */
changeBuffer.MLastAccessedDate = date;
changeBuffer.MLastUpdatedDate = date;
changeBuffer.MLastUpdatedTime = time;
if (ChangeDirectoryEntry(G.filename, &changeBuffer,
MLastAccessedDateBit | MLastUpdatedDateBit | MLastUpdatedTimeBit,
0))
{
if (uO.qflag)
Info(slide, 0x201, ((char *)slide,
"warning: cannot set times for %s\n",
FnFilter1(G.filename)));
else
Info(slide, 0x201, ((char *)slide,
" (warning) cannot set times"));
}
}
/*---------------------------------------------------------------------------
Change the file permissions from default ones to those stored in the
zipfile.
---------------------------------------------------------------------------*/
if (chmod(G.filename, 0xffff & G.pInfo->file_attr))
perror("chmod (file attributes) error");
} /* end function close_outfile() */
#ifdef TIMESTAMP
/***************************/
/* Function stamp_file() */
/***************************/
int stamp_file(fname, modtime)
ZCONST char *fname;
time_t modtime;
{
ztimbuf tp;
tp.modtime = tp.actime = modtime;
return (utime(fname, &tp));
} /* end function stamp_file() */
#endif /* TIMESTAMP */
/************************/
/* Function version() */
/************************/
void version(__G)
__GDEF
{
int len;
#if defined(__IBMC__) || defined(__WATCOMC__) || defined(_MSC_VER)
char buf[80];
#endif
len = sprintf((char *)slide, LoadFarString(CompiledWith),
#if defined(__GNUC__)
# ifdef __EMX__ /* __EMX__ is defined as "1" only (sigh) */
"emx+gcc ", __VERSION__,
# else
"gcc/2 ", __VERSION__,
# endif
#elif defined(__WATCOMC__)
"Watcom C", (sprintf(buf, " (__WATCOMC__ = %d)", __WATCOMC__), buf),
#elif defined(__TURBOC__)
# ifdef __BORLANDC__
"Borland C++",
# if (__BORLANDC__ < 0x0460)
" 1.0",
# elif (__BORLANDC__ == 0x0460)
" 1.5", /* from Kai Uwe: three less than DOS */
# else
" 2.0", /* (__BORLANDC__ == 0x0500)? */
# endif
# else
"Turbo C", /* these are probably irrelevant */
# if (__TURBOC__ >= 661)
"++ 1.0 or later",
( run in 0.522 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )