~ubuntu-branches/ubuntu/jaunty/xulrunner-1.9/jaunty

« back to all changes in this revision

Viewing changes to mozilla/security/nss/cmd/lib/secutil.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabien Tassin, Sasa Bodiroza, Fabien Tassin, Alexander Sack
  • Date: 2008-09-02 11:54:00 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20080902115400-yfy26crvszpalvg5
Tags: 1.9.0.2+build3+nobinonly-0ubuntu1
[ Sasa Bodiroza ]
* In debian/rules:
  - Set 644 chmod to png files (LP: #252793) [Patch by Paolo Naldini]

[ Fabien Tassin ]
* improve create-build-system.sh to detect build-tree directory
  when embedded tarball is used. Fix un-escaped variables.
  Create build-system.tar.gz in the debian directory to prevent
  cdbs to check and unpack it during the build
  - update debian/create-build-system.sh
* Fix variables when an embedded tarball is used
  - update debian/rules
* Fix buffer overflow in realpath() at runtime and drop -U_FORTIFY_SOURCE
  from CPPFLAGS (LP: #263014)
  - add debian/patches/bz412610_att335369_realpath_overflow.patch
  - update debian/patches/series

[ Alexander Sack <asac@jwsdot.com> ]
* introduce preferred plugins by mime-type experimental feature;
  you can now set a pref to explicitly select a plugin to serve a particilar
  mime-type; patch contains further documentation.
  - add debian/patches/bzXXX_plugin_for_mimetype_pref.patch
  - update debian/patches/series
* drop patches applied upstream
  - drop bz120380_att326044.patch (fixed by bz442629)
  - update debian/patches/series

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
char *
214
214
SECU_FilePasswd(PK11SlotInfo *slot, PRBool retry, void *arg)
215
215
{
216
 
    unsigned char phrase[200];
 
216
    char* phrases, *phrase;
217
217
    PRFileDesc *fd;
218
218
    PRInt32 nb;
219
219
    char *pwFile = arg;
220
220
    int i;
 
221
    const long maxPwdFileSize = 4096;
 
222
    char* tokenName = NULL;
 
223
    int tokenLen = 0;
221
224
 
222
225
    if (!pwFile)
223
226
        return 0;
224
227
 
225
228
    if (retry) {
226
229
        return 0;  /* no good retrying - the files contents will be the same */
227
 
    } 
 
230
    }
 
231
 
 
232
    phrases = PORT_ZAlloc(maxPwdFileSize);
 
233
 
 
234
    if (!phrases) {
 
235
        return 0; /* out of memory */
 
236
    }
228
237
 
229
238
    fd = PR_Open(pwFile, PR_RDONLY, 0);
230
239
    if (!fd) {
231
240
        fprintf(stderr, "No password file \"%s\" exists.\n", pwFile);
 
241
        PORT_Free(phrases);
232
242
        return NULL;
233
243
    }
234
244
 
235
 
    nb = PR_Read(fd, phrase, sizeof(phrase));
 
245
    nb = PR_Read(fd, phrases, maxPwdFileSize);
236
246
  
237
247
    PR_Close(fd);
238
 
    /* handle the Windows EOL case */
 
248
 
 
249
    if (nb == 0) {
 
250
        fprintf(stderr,"password file contains no data\n");
 
251
        PORT_Free(phrases);
 
252
        return NULL;
 
253
    }
 
254
 
 
255
    if (slot) {
 
256
        tokenName = PK11_GetTokenName(slot);
 
257
        if (tokenName) {
 
258
            tokenLen = PORT_Strlen(tokenName);
 
259
        }
 
260
    }
239
261
    i = 0;
240
 
    while (phrase[i] != '\r' && phrase[i] != '\n' && i < nb) i++;
241
 
    phrase[i] = '\0';
242
 
    if (nb == 0) {
243
 
        fprintf(stderr,"password file contains no data\n");
244
 
        return NULL;
245
 
    }
246
 
    return (char*) PORT_Strdup((char*)phrase);
 
262
    do
 
263
    {
 
264
        int startphrase = i;
 
265
        int phraseLen;
 
266
 
 
267
        /* handle the Windows EOL case */
 
268
        while (phrases[i] != '\r' && phrases[i] != '\n' && i < nb) i++;
 
269
        /* terminate passphrase */
 
270
        phrases[i++] = '\0';
 
271
        /* clean up any EOL before the start of the next passphrase */
 
272
        while ( (i<nb) && (phrases[i] == '\r' || phrases[i] == '\n')) {
 
273
            phrases[i++] = '\0';
 
274
        }
 
275
        /* now analyze the current passphrase */
 
276
        phrase = &phrases[startphrase];
 
277
        if (!tokenName)
 
278
            break;
 
279
        if (PORT_Strncmp(phrase, tokenName, tokenLen)) continue;
 
280
        phraseLen = PORT_Strlen(phrase);
 
281
        if (phraseLen < (tokenLen+1)) continue;
 
282
        if (phrase[tokenLen] != ':') continue;
 
283
        phrase = &phrase[tokenLen+1];
 
284
        break;
 
285
 
 
286
    } while (i<nb);
 
287
 
 
288
    phrase = PORT_Strdup((char*)phrase);
 
289
    PORT_Free(phrases);
 
290
    return phrase;
247
291
}
248
292
 
249
293
char *
1998
2042
        int snPresent = (kid->authCertSerialNumber.data &&
1999
2043
                         kid->authCertSerialNumber.len);
2000
2044
 
2001
 
        if ((keyIDPresent && !issuerPresent && !snPresent) ||
2002
 
            (!keyIDPresent && issuerPresent && snPresent)) {
2003
 
            /* all is well */
2004
 
        } else {
2005
 
            SECU_Indent(out, level);
2006
 
            fprintf(out, 
2007
 
            "Error: KeyID OR (Issuer AND Serial) must be present, not both.\n");
2008
 
        }
2009
2045
        if (keyIDPresent)
2010
2046
            SECU_PrintAsHex(out, &kid->keyID, "Key ID", level);
2011
2047
        if (issuerPresent)
2065
2101
                pPoint->distPoint.fullName != NULL) {
2066
2102
                secu_PrintGeneralNames(out, pPoint->distPoint.fullName, NULL,
2067
2103
                                       level);
2068
 
#if defined(LATER)
2069
 
            } else if (pPoint->distPointType == relativeDistinguishedName) {
2070
 
                /* print the relative name */
2071
 
#endif
 
2104
            } else if (pPoint->distPointType == relativeDistinguishedName &&
 
2105
                       pPoint->distPoint.relativeName.avas) {
 
2106
                SECU_PrintRDN(out, &pPoint->distPoint.relativeName, "RDN", 
 
2107
                              level);
2072
2108
            } else if (pPoint->derDistPoint.data) {
2073
2109
                SECU_PrintAny(out, &pPoint->derDistPoint, "Point", level);
2074
2110
            }
2295
2331
    }
2296
2332
}
2297
2333
 
 
2334
/* An RDN is a subset of a DirectoryName, and we already know how to
 
2335
 * print those, so make a directory name out of the RDN, and print it.
 
2336
 */
 
2337
void
 
2338
SECU_PrintRDN(FILE *out, CERTRDN *rdn, char *msg, int level)
 
2339
{
 
2340
    CERTName name;
 
2341
    CERTRDN *rdns[2];
 
2342
 
 
2343
    name.arena = NULL;
 
2344
    name.rdns  = rdns;
 
2345
    rdns[0] = rdn;
 
2346
    rdns[1] = NULL;
 
2347
    SECU_PrintName(out, &name, msg, level);
 
2348
}
2298
2349
 
2299
2350
void
2300
2351
SECU_PrintName(FILE *out, CERTName *name, char *msg, int level)
3276
3327
    int i, j;
3277
3328
    int lcmd = 0, lopt = 0;
3278
3329
 
3279
 
    optstring = (char *)PORT_Alloc(cmd->numCommands + 2*cmd->numOptions);
 
3330
    optstring = (char *)PORT_Alloc(cmd->numCommands + 2*cmd->numOptions+1);
3280
3331
    if (optstring == NULL)
3281
3332
        return SECFailure;
3282
3333