Subversion Repositories SvarDOS

Rev

Rev 1963 | Rev 1965 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1963 Rev 1964
Line 22... Line 22...
22
 
22
 
23
/* validate a filename (8+3, no weird characters, etc). returns 0 on success,
23
/* validate a filename (8+3, no weird characters, etc). returns 0 on success,
24
 * nonzero otherwise. */
24
 * nonzero otherwise. */
25
static int validfilename(const char *fname) {
25
static int validfilename(const char *fname) {
26
  int i, i2;
26
  int i, i2;
27
  char *validchars = "!#$%&'()-@^_`{}~";
27
  const char *validchars = "!#$%&'()-@^_`{}~";
28
  int elemlen = 0;
28
  int elemlen = 0;
29
  int elemmaxlen = 8; /* switches from 8 to 3 depending wheter I am analyzing
29
  int elemmaxlen = 8; /* switches from 8 to 3 depending wheter I am analyzing
30
                         a filename or an extension */
30
                         a filename or an extension */
31
  /* look for invalid chars in the entire string, and check the length of the
31
  /* look for invalid chars in the entire string, and check the length of the
32
   * element at the same time */
32
   * element at the same time */
Line 156... Line 156...
156
    if ((curzipnode->flags & ZIP_FLAG_ISADIR) != 0) goto DELETE_ZIP_NODE;
156
    if ((curzipnode->flags & ZIP_FLAG_ISADIR) != 0) goto DELETE_ZIP_NODE;
157
 
157
 
158
    /* abort if entry is encrypted */
158
    /* abort if entry is encrypted */
159
    if ((curzipnode->flags & ZIP_FLAG_ENCRYPTED) != 0) {
159
    if ((curzipnode->flags & ZIP_FLAG_ENCRYPTED) != 0) {
160
      outputnl(svarlang_str(3, 20)); /* "ERROR: Package contains an encrypted file:" */
160
      outputnl(svarlang_str(3, 20)); /* "ERROR: Package contains an encrypted file:" */
161
      printf(" %s\n", curzipnode->filename);
161
      outputnl(curzipnode->filename);
162
      goto RAII_ERR;
162
      goto RAII_ERR;
163
    }
163
    }
164
 
164
 
165
    /* abort if file is compressed with an unsupported method */
165
    /* abort if file is compressed with an unsupported method */
166
    if ((curzipnode->compmethod != ZIP_METH_STORE) && (curzipnode->compmethod != ZIP_METH_DEFLATE)) { /* unsupported compression method */
166
    if ((curzipnode->compmethod != ZIP_METH_STORE) && (curzipnode->compmethod != ZIP_METH_DEFLATE)) { /* unsupported compression method */
167
      kitten_printf(8, 2, curzipnode->compmethod); /* "ERROR: Package contains a file compressed with an unsupported method (%d):" */
167
      kitten_printf(8, 2, curzipnode->compmethod); /* "ERROR: Package contains a file compressed with an unsupported method (%d):" */
168
      outputnl("");
168
      outputnl("");
169
      printf(" %s\n", curzipnode->filename);
169
      outputnl(curzipnode->filename);
170
      goto RAII_ERR;
170
      goto RAII_ERR;
171
    }
171
    }
172
 
172
 
173
    /* is it the appinfo file? detach it from the list for now */
173
    /* is it the appinfo file? detach it from the list for now */
174
    if (strstr(curzipnode->filename, "appinfo\\") == curzipnode->filename) {
174
    if (strstr(curzipnode->filename, "appinfo\\") == curzipnode->filename) {
Line 284... Line 284...
284
    if (msgptr != NULL) {
284
    if (msgptr != NULL) {
285
      if (strcasecmp(buff, "warn") == 0) {
285
      if (strcasecmp(buff, "warn") == 0) {
286
        /* print a visual delimiter */
286
        /* print a visual delimiter */
287
        if (warncount == 0) {
287
        if (warncount == 0) {
288
          outputnl("");
288
          outputnl("");
289
          for (i = 0; i < 79; i++) putchar('*');
289
          for (i = 0; i < 79; i++) output("*");
290
          outputnl("");
290
          outputnl("");
291
        }
291
        }
292
        /* there may be more than one "warn" line */
292
        /* there may be more than one "warn" line */
293
        outputnl(msgptr);
293
        outputnl(msgptr);
294
        warncount++;
294
        warncount++;
Line 307... Line 307...
307
}
307
}
308
 
308
 
309
 
309
 
310
/* install a package that has been prepared already. returns 0 on success,
310
/* install a package that has been prepared already. returns 0 on success,
311
 * or a negative value on error, or a positive value on warning */
311
 * or a negative value on error, or a positive value on warning */
312
int pkginstall_installpackage(const char *pkgname, const char *dosdir, const struct customdirs *dirlist, struct ziplist *ziplinkedlist, FILE *zipfd, char bootdrive) {
312
int pkginstall_installpackage(const char *pkgname, const char *dosdir, const struct customdirs *dirlist, struct ziplist *ziplinkedlist, FILE *zipfd, char bootdrive, unsigned char *buff15k) {
313
  char buff[256];
313
  char buff[256];
314
  char fulldestfilename[256];
314
  char fulldestfilename[256];
315
  char *shortfile;
315
  char *shortfile;
316
  long filesextractedsuccess = 0, filesextractedfailure = 0;
316
  long filesextractedsuccess = 0, filesextractedfailure = 0;
317
  struct ziplist *curzipnode;
317
  struct ziplist *curzipnode;
Line 327... Line 327...
327
  output(ziplinkedlist->filename);
327
  output(ziplinkedlist->filename);
328
  output(" -> ");
328
  output(" -> ");
329
  output(buff);
329
  output(buff);
330
  strcat(buff, pkgname);
330
  strcat(buff, pkgname);
331
  strcat(buff, ".lsm");
331
  strcat(buff, ".lsm");
332
  unzip_result = zip_unzip(zipfd, ziplinkedlist, buff);
332
  unzip_result = zip_unzip(zipfd, ziplinkedlist, buff, buff15k);
333
  outputnl("");
333
  outputnl("");
334
  if (unzip_result != 0) {
334
  if (unzip_result != 0) {
335
    kitten_printf(10, 4, unzip_result); /* "ERROR: unzip failure (%d)" */
335
    kitten_printf(10, 4, unzip_result); /* "ERROR: unzip failure (%d)" */
336
    outputnl("");
336
    outputnl("");
337
    return(-1);
337
    return(-1);
Line 362... Line 362...
362
 
362
 
363
    /* Now unzip the file */
363
    /* Now unzip the file */
364
    output(curzipnode->filename);
364
    output(curzipnode->filename);
365
    output(" -> ");
365
    output(" -> ");
366
    output(buff);
366
    output(buff);
367
    unzip_result = zip_unzip(zipfd, curzipnode, fulldestfilename);
367
    unzip_result = zip_unzip(zipfd, curzipnode, fulldestfilename, buff15k);
368
    outputnl("");
368
    outputnl("");
369
    if (unzip_result != 0) {
369
    if (unzip_result != 0) {
370
      kitten_printf(10, 4, unzip_result); /* "ERROR: unzip failure (%d)" */
370
      kitten_printf(10, 4, unzip_result); /* "ERROR: unzip failure (%d)" */
371
      outputnl("");
371
      outputnl("");
372
      filesextractedfailure += 1;
372
      filesextractedfailure += 1;