Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/libsmb/libsmb_path.c

    r414 r745  
    88   Copyright (C) Derrell Lipman 2003-2008
    99   Copyright (C) Jeremy Allison 2007, 2008
    10    
     10
    1111   This program is free software; you can redistribute it and/or modify
    1212   it under the terms of the GNU General Public License as published by
    1313   the Free Software Foundation; either version 3 of the License, or
    1414   (at your option) any later version.
    15    
     15
    1616   This program is distributed in the hope that it will be useful,
    1717   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1818   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1919   GNU General Public License for more details.
    20    
     20
    2121   You should have received a copy of the GNU General Public License
    2222   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    6161        size_t newlen = 1;
    6262        char *p, *dest;
    63        
     63
    6464        if (old_length == 0) {
    6565                return 0;
    6666        }
    67        
     67
    6868        *pp_dest = NULL;
    6969        for (i = 0; i < old_length; ) {
    7070                unsigned char character = src[i++];
    71                
     71
    7272                if (character == '%') {
    7373                        int a = i+1 < old_length ? hex2int(src[i]) : -1;
    7474                        int b = i+1 < old_length ? hex2int(src[i+1]) : -1;
    75                        
     75
    7676                        /* Replace valid sequence */
    7777                        if (a != -1 && b != -1) {
     
    8888                newlen++;
    8989        }
    90        
     90
    9191        dest = TALLOC_ARRAY(ctx, char, newlen);
    9292        if (!dest) {
    9393                return err_count;
    9494        }
    95        
     95
    9696        err_count = 0;
    9797        for (p = dest, i = 0; i < old_length; ) {
    9898                unsigned char character = src[i++];
    99                
     99
    100100                if (character == '%') {
    101101                        int a = i+1 < old_length ? hex2int(src[i]) : -1;
    102102                        int b = i+1 < old_length ? hex2int(src[i+1]) : -1;
    103                        
     103
    104104                        /* Replace valid sequence */
    105105                        if (a != -1 && b != -1) {
     
    116116                *p++ = character;
    117117        }
    118        
     118
    119119        *p = '\0';
    120120        *pp_dest = dest;
     
    130130        char *pdest;
    131131        int ret = urldecode_talloc(frame, &pdest, src);
    132        
     132
    133133        if (pdest) {
    134134                strlcpy(dest, pdest, max_dest_len);
     
    152152{
    153153        char hex[] = "0123456789ABCDEF";
    154        
     154
    155155        for (; *src != '\0' && max_dest_len >= 3; src++) {
    156                
     156
    157157                if ((*src < '0' &&
    158158                     *src != '-' &&
     
    173173                }
    174174        }
    175        
     175
    176176        *dest++ = '\0';
    177177        max_dest_len--;
    178        
     178
    179179        return max_dest_len;
    180180}
     
    236236        char *workgroup = NULL;
    237237        int len;
    238        
     238
    239239        /* Ensure these returns are at least valid pointers. */
    240240        *pp_server = talloc_strdup(ctx, "");
     
    243243        *pp_user = talloc_strdup(ctx, "");
    244244        *pp_password = talloc_strdup(ctx, "");
    245        
     245
    246246        if (!*pp_server || !*pp_share || !*pp_path ||
    247247            !*pp_user || !*pp_password) {
    248248                return -1;
    249249        }
    250        
     250
    251251        /*
    252252         * Assume we wont find an authentication domain to parse, so default
     
    257257                        talloc_strdup(ctx, smbc_getWorkgroup(context));
    258258        }
    259        
     259
    260260        if (pp_options) {
    261261                *pp_options = talloc_strdup(ctx, "");
    262262        }
    263263        s = talloc_strdup(ctx, fname);
    264        
     264
    265265        /* see if it has the right prefix */
    266266        len = strlen(SMBC_PREFIX);
     
    268268                return -1; /* What about no smb: ? */
    269269        }
    270        
     270
    271271        p = s + len;
    272        
     272
    273273        /* Watch the test below, we are testing to see if we should exit */
    274        
     274
    275275        if (strncmp(p, "//", 2) && strncmp(p, "\\\\", 2)) {
    276276                DEBUG(1, ("Invalid path (does not begin with smb://"));
    277277                return -1;
    278278        }
    279        
     279
    280280        p += 2;  /* Skip the double slash */
    281        
     281
    282282        /* See if any options were specified */
    283283        if ((q = strrchr(p, '?')) != NULL ) {
    284284                /* There are options.  Null terminate here and point to them */
    285285                *q++ = '\0';
    286                
     286
    287287                DEBUG(4, ("Found options '%s'", q));
    288                
     288
    289289                /* Copy the options */
    290290                if (pp_options && *pp_options != NULL) {
     
    293293                }
    294294        }
    295        
     295
    296296        if (*p == '\0') {
    297297                goto decoding;
    298298        }
    299        
     299
    300300        if (*p == '/') {
    301301                int wl = strlen(smbc_getWorkgroup(context));
    302                
     302
    303303                if (wl > 16) {
    304304                        wl = 16;
    305305                }
    306                
     306
    307307                *pp_server = talloc_strdup(ctx, smbc_getWorkgroup(context));
    308308                if (!*pp_server) {
     
    312312                return 0;
    313313        }
    314        
     314
    315315        /*
    316316         * ok, its for us. Now parse out the server, share etc.
     
    319319         * exists ...
    320320         */
    321        
     321
    322322        /* check that '@' occurs before '/', if '/' exists at all */
    323323        q = strchr_m(p, '@');
     
    326326                char *userinfo = NULL;
    327327                const char *u;
    328                
     328
    329329                next_token_no_ltrim_talloc(ctx, &p, &userinfo, "@");
    330330                if (!userinfo) {
     
    332332                }
    333333                u = userinfo;
    334                
     334
    335335                if (strchr_m(u, ';')) {
    336336                        next_token_no_ltrim_talloc(ctx, &u, &workgroup, ";");
     
    342342                        }
    343343                }
    344                
     344
    345345                if (strchr_m(u, ':')) {
    346346                        next_token_no_ltrim_talloc(ctx, &u, pp_user, ":");
     
    359359                }
    360360        }
    361        
     361
    362362        if (!next_token_talloc(ctx, &p, pp_server, "/")) {
    363363                return -1;
    364364        }
    365        
     365
    366366        if (*p == (char)0) {
    367367                goto decoding;  /* That's it ... */
    368368        }
    369        
     369
    370370        if (!next_token_talloc(ctx, &p, pp_share, "/")) {
    371371                return -1;
    372372        }
    373        
     373
    374374        /*
    375375         * Prepend a leading slash if there's a file path, as required by
     
    387387        }
    388388        string_replace(*pp_path, '/', '\\');
    389        
     389
    390390decoding:
    391        
    392391        (void) urldecode_talloc(ctx, pp_path, *pp_path);
    393392        (void) urldecode_talloc(ctx, pp_server, *pp_server);
     
    408407                                           *pp_user,
    409408                                           *pp_password);
    410        
    411409        return 0;
    412410}
Note: See TracChangeset for help on using the changeset viewer.