~ubuntu-branches/ubuntu/karmic/unzip/karmic

« back to all changes in this revision

Viewing changes to flexos/flexos.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-2003 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.
95
95
        notfirstcall = TRUE;
96
96
 
97
97
        if (!iswild(wildspec)) {
98
 
            strcpy(matchname, wildspec);
 
98
            strncpy(matchname, wildspec, FILNAMSIZ);
 
99
            matchname[FILNAMSIZ-1] = '\0';
99
100
            have_dirname = FALSE;
100
101
            dir = NULL;
101
102
            return matchname;
114
115
            if ((dirname = (char *)malloc(dirnamelen+1)) == (char *)NULL) {
115
116
                Info(slide, 1, ((char *)slide,
116
117
                  LoadFarString(CantAllocateWildcard)));
117
 
                strcpy(matchname, wildspec);
 
118
                strncpy(matchname, wildspec, FILNAMSIZ);
 
119
                matchname[FILNAMSIZ-1] = '\0';
118
120
                return matchname;   /* but maybe filespec was not a wildcard */
119
121
            }
120
122
/* GRR:  cannot strip trailing char for opendir since might be "d:/" or "d:"
137
139
                strcpy(fnamestart, file->d_name);
138
140
                if (strrchr(fnamestart, '.') == (char *)NULL)
139
141
                    strcat(fnamestart, ".");
140
 
                if (match(fnamestart, wildname, 1) &&  /* 1 == ignore case */
 
142
                if (match(fnamestart, wildname, 1 WISEP) && /* 1=ignore case */
141
143
                    /* skip "." and ".." directory entries */
142
144
                    strcmp(fnamestart, ".") && strcmp(fnamestart, "..")) {
143
145
                    Trace((stderr, "do_wild:  match() succeeds\n"));
161
163
 
162
164
        /* return the raw wildspec in case that works (e.g., directory not
163
165
         * searchable, but filespec was not wild and file is readable) */
164
 
        strcpy(matchname, wildspec);
 
166
        strncpy(matchname, wildspec, FILNAMSIZ);
 
167
        matchname[FILNAMSIZ-1] = '\0';
165
168
        return matchname;
166
169
    }
167
170
 
188
191
        strcpy(fnamestart, file->d_name);
189
192
        if (strrchr(fnamestart, '.') == (char *)NULL)
190
193
            strcat(fnamestart, ".");
191
 
        if (match(fnamestart, wildname, 1)) {   /* 1 == ignore case */
 
194
        if (match(fnamestart, wildname, 1 WISEP)) {     /* 1 == ignore case */
192
195
            Trace((stderr, "do_wild:  match() succeeds\n"));
193
196
            /* remove trailing dot */
194
197
            fnamestart += strlen(fnamestart) - 1;