~ubuntu-branches/ubuntu/raring/unzip/raring

« back to all changes in this revision

Viewing changes to aosvs/aosvs.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2005-09-29 17:02:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050929170250-my63eoy88vv1gd7e
Tags: 5.52-3ubuntu2
* SECURITY UPDATE: Fix file permission modification race.
* unix/unix.c: Use fchmod() instead of chmod() to change permissions on the
  files unzip actually created, not the files another attacker might have
  hardlinked to in the meantime.
* CAN-2005-2475

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
  Copyright (c) 1990-2004 Info-ZIP.  All rights reserved.
 
2
  Copyright (c) 1990-2005 Info-ZIP.  All rights reserved.
3
3
 
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.
111
111
 
112
112
 
113
113
/**********************/
114
 
/* Function do_wild() */   /* for porting:  dir separator; match(ignore_case) */
 
114
/* Function do_wild() */   /* for porting: dir separator; match(ignore_case) */
115
115
/**********************/
116
116
 
117
117
char *do_wild(__G__ wildspec)
132
132
        notfirstcall = TRUE;
133
133
 
134
134
        if (!iswild(wildspec)) {
135
 
            strcpy(matchname, wildspec);
 
135
            strncpy(matchname, wildspec, FILNAMSIZ);
 
136
            matchname[FILNAMSIZ-1] = '\0';
136
137
            have_dirname = FALSE;
137
138
            dir = NULL;
138
139
            return matchname;
150
151
            if ((dirname = (char *)malloc(dirnamelen+1)) == (char *)NULL) {
151
152
                Info(slide, 0x201, ((char *)slide,
152
153
                  "warning:  cannot allocate wildcard buffers\n"));
153
 
                strcpy(matchname, wildspec);
 
154
                strncpy(matchname, wildspec, FILNAMSIZ);
 
155
                matchname[FILNAMSIZ-1] = '\0';
154
156
                return matchname;   /* but maybe filespec was not a wildcard */
155
157
            }
156
158
            strncpy(dirname, wildspec, dirnamelen);
163
165
                Trace((stderr, "do_wild:  readdir returns %s\n",
164
166
                  FnFilter1(file->d_name)));
165
167
                if (file->d_name[0] == '.' && wildname[0] != '.')
166
 
                    continue;  /* Unix:  '*' and '?' do not match leading dot */
167
 
                if (match(file->d_name, wildname, 0) &&  /* 0 == case sens. */
 
168
                    continue; /* Unix:  '*' and '?' do not match leading dot */
 
169
                if (match(file->d_name, wildname, 0 WISEP) && /* 0=case sens.*/
168
170
                    /* skip "." and ".." directory entries */
169
171
                    strcmp(file->d_name, ".") && strcmp(file->d_name, "..")) {
170
172
                    Trace((stderr, "do_wild:  match() succeeds\n"));
183
185
 
184
186
        /* return the raw wildspec in case that works (e.g., directory not
185
187
         * searchable, but filespec was not wild and file is readable) */
186
 
        strcpy(matchname, wildspec);
 
188
        strncpy(matchname, wildspec, FILNAMSIZ);
 
189
        matchname[FILNAMSIZ-1] = '\0';
187
190
        return matchname;
188
191
    }
189
192
 
204
207
          FnFilter1(file->d_name)));
205
208
        if (file->d_name[0] == '.' && wildname[0] != '.')
206
209
            continue;   /* Unix:  '*' and '?' do not match leading dot */
207
 
        if (match(file->d_name, wildname, 0)) {   /* 0 == don't ignore case */
 
210
        if (match(file->d_name, wildname, 0 WISEP)) {   /* 0 ==  case sens. */
208
211
            Trace((stderr, "do_wild:  match() succeeds\n"));
209
212
            if (have_dirname) {
210
213
                /* strcpy(matchname, dirname); */
398
401
        case VMS_:
399
402
        case ACORN_:
400
403
        case ATARI_:
 
404
        case ATHEOS_:
401
405
        case BEOS_:
402
406
        case QDOS_:
403
407
        case TANDEM_:
658
662
        != (RO_extra_block *)NULL)
659
663
    {
660
664
        /* file *must* have a RISC OS extra field */
661
 
        long ft = (long)makelong((ef_spark->loadaddr);
 
665
        long ft = (long)makelong(ef_spark->loadaddr);
662
666
        /*32-bit*/
663
667
        if (lastcomma) {
664
668
            pp = lastcomma + 1;