security/nss/lib/jar/jarint.c

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 /*
     6  * Internal libjar routines.
     7  */
     9 #include "jar.h"
    10 #include "jarint.h"
    12 /*-----------------------------------------------------------------------
    13  * JAR_FOPEN_to_PR_Open
    14  * Translate JAR_FOPEN arguments to PR_Open arguments
    15  */
    16 PRFileDesc*
    17 JAR_FOPEN_to_PR_Open(const char* name, const char *mode)
    18 {
    20     PRIntn  prflags=0, prmode=0;
    22     /* Get read/write flags */
    23     if (strchr(mode, 'r') && !strchr(mode, '+')) {
    24 	prflags |= PR_RDONLY;
    25     } else if( (strchr(mode, 'w') || strchr(mode, 'a')) &&
    26 	!strchr(mode,'+') ) {
    27 	prflags |= PR_WRONLY;
    28     } else {
    29 	prflags |= PR_RDWR;
    30     }
    32     /* Create a new file? */
    33     if (strchr(mode, 'w') || strchr(mode, 'a')) {
    34 	prflags |= PR_CREATE_FILE;
    35     }
    37     /* Append? */
    38     if (strchr(mode, 'a')) {
    39 	prflags |= PR_APPEND;
    40     }
    42     /* Truncate? */
    43     if (strchr(mode, 'w')) {
    44 	prflags |= PR_TRUNCATE;
    45     }
    47     /* We can't do umask because it isn't XP.  Choose some default
    48 	   mode for created files */
    49     prmode = 0755;
    51     return PR_Open(name, prflags, prmode);
    52 }

mercurial