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/source4/lib/registry/patchfile.c

    r414 r745  
    55   Copyright (C) Jelmer Vernooij 2004-2007
    66   Copyright (C) Wilco Baan Hofman 2006
    7    Copyright (C) Matthias Dieter Wallnöfer 2008
     7   Copyright (C) Matthias Dieter Wallnöfer 2008-2010
    88
    99   This program is free software; you can redistribute it and/or modify
     
    2727
    2828_PUBLIC_ WERROR reg_preg_diff_load(int fd,
    29                                    struct smb_iconv_convenience *iconv_convenience,
    3029                                   const struct reg_diff_callbacks *callbacks,
    3130                                   void *callback_data);
    3231
    3332_PUBLIC_ WERROR reg_dotreg_diff_load(int fd,
    34                                      struct smb_iconv_convenience *iconv_convenience,
    3533                                     const struct reg_diff_callbacks *callbacks,
    3634                                     void *callback_data);
     
    4543                             void *callback_data)
    4644{
    47         int i;
     45        unsigned int i;
    4846        struct registry_key *t1 = NULL, *t2 = NULL;
    4947        char *tmppath;
     
    8785
    8886                if (!W_ERROR_IS_OK(error2) && !W_ERROR_EQUAL(error2, WERR_BADFILE)) {
    89                         DEBUG(0, ("Error occured while getting subkey by name: %s\n",
     87                        DEBUG(0, ("Error occurred while getting subkey by name: %s\n",
    9088                                win_errstr(error2)));
    9189                        talloc_free(mem_ctx);
     
    9694                /* didn't have such a subkey and therefore add a del diff */
    9795                tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1);
     96                if (tmppath == NULL) {
     97                        DEBUG(0, ("Out of memory\n"));
     98                        talloc_free(mem_ctx);
     99                        return WERR_NOMEM;
     100                }
    98101                if (!W_ERROR_IS_OK(error2))
    99102                        callbacks->del_key(callback_data, tmppath);
     
    102105                error1 = reg_open_key(mem_ctx, oldkey, keyname1, &t1);
    103106                if (!W_ERROR_IS_OK(error1)) {
    104                         DEBUG(0, ("Error occured while getting subkey by name: %s\n",
     107                        DEBUG(0, ("Error occurred while getting subkey by name: %s\n",
    105108                        win_errstr(error1)));
    106109                        talloc_free(mem_ctx);
     
    155158                }
    156159
    157                 /* oldkey didn't have such a subkey, add add diff */
     160                /* oldkey didn't have such a subkey, add a add diff */
    158161                tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1);
     162                if (tmppath == NULL) {
     163                        DEBUG(0, ("Out of memory\n"));
     164                        talloc_free(mem_ctx);
     165                        return WERR_NOMEM;
     166                }
    159167                callbacks->add_key(callback_data, tmppath);
    160168
     
    162170                error1 = reg_open_key(mem_ctx, newkey, keyname1, &t2);
    163171                if (!W_ERROR_IS_OK(error1)) {
    164                         DEBUG(0, ("Error occured while getting subkey by name: %s\n",
     172                        DEBUG(0, ("Error occurred while getting subkey by name: %s\n",
    165173                        win_errstr(error1)));
    166174                        talloc_free(mem_ctx);
     
    176184                const char *name;
    177185                uint32_t type1, type2;
    178                 DATA_BLOB contents1, contents2;
     186                DATA_BLOB contents1 = { NULL, 0 }, contents2 = { NULL, 0 };
    179187
    180188                error1 = reg_key_get_value_by_index(mem_ctx, newkey, i,
     
    203211
    204212                if (W_ERROR_IS_OK(error2)
    205                         && (data_blob_cmp(&contents1, &contents2) == 0)
    206                         && (type1 == type2))
     213                    && (data_blob_cmp(&contents1, &contents2) == 0)
     214                    && (type1 == type2)) {
     215                        talloc_free(discard_const_p(char, name));
     216                        talloc_free(contents1.data);
     217                        talloc_free(contents2.data);
    207218                        continue;
     219                }
    208220
    209221                callbacks->set_value(callback_data, path, name,
    210222                                     type1, contents1);
     223
     224                talloc_free(discard_const_p(char, name));
     225                talloc_free(contents1.data);
     226                talloc_free(contents2.data);
    211227        }
    212228
     
    215231                const char *name;
    216232                uint32_t type;
    217                 DATA_BLOB contents;
     233                DATA_BLOB contents = { NULL, 0 };
    218234
    219235                error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &name,
     
    232248                        error2 = WERR_BADFILE;
    233249
    234                 if (W_ERROR_IS_OK(error2))
     250                if (W_ERROR_IS_OK(error2)) {
     251                        talloc_free(discard_const_p(char, name));
     252                        talloc_free(contents.data);
    235253                        continue;
     254                }
    236255
    237256                if (!W_ERROR_EQUAL(error2, WERR_BADFILE)) {
     
    243262
    244263                callbacks->del_value(callback_data, path, name);
     264
     265                talloc_free(discard_const_p(char, name));
     266                talloc_free(contents.data);
    245267        }
    246268
     
    257279                                  void *callback_data)
    258280{
    259         int i;
     281        unsigned int i;
    260282        WERROR error;
    261283
     
    281303                }
    282304
     305                /* if "r1" is NULL (old hive) and "r2" isn't (new hive) then
     306                 * the hive doesn't exist yet and we have to generate an add
     307                 * diff */
     308                if ((r1 == NULL) && (r2 != NULL)) {
     309                        callbacks->add_key(callback_data,
     310                                           reg_predefined_keys[i].name);
     311                }
     312                /* if "r1" isn't NULL (old hive) and "r2" is (new hive) then
     313                 * the hive shouldn't exist anymore and we have to generate a
     314                 * del diff */
     315                if ((r1 != NULL) && (r2 == NULL)) {
     316                        callbacks->del_key(callback_data,
     317                                           reg_predefined_keys[i].name);
     318                }
     319
    283320                error = reg_generate_diff_key(r1, r2,
    284321                        reg_predefined_keys[i].name, callbacks,
     
    300337 */
    301338_PUBLIC_ WERROR reg_diff_load(const char *filename,
    302                               struct smb_iconv_convenience *iconv_convenience,
    303339                              const struct reg_diff_callbacks *callbacks,
    304340                              void *callback_data)
     
    334370        if (strncmp(hdr, "PReg", 4) == 0) {
    335371                /* Must be a GPO Registry.pol file */
    336                 return reg_preg_diff_load(fd, iconv_convenience, callbacks, callback_data);
     372                return reg_preg_diff_load(fd, callbacks, callback_data);
    337373        } else {
    338374                /* Must be a normal .REG file */
    339                 return reg_dotreg_diff_load(fd, iconv_convenience, callbacks, callback_data);
     375                return reg_dotreg_diff_load(fd, callbacks, callback_data);
    340376        }
    341377}
     
    353389        /* Recursively create the path */
    354390        buf = talloc_strdup(ctx, key_name);
     391        W_ERROR_HAVE_NO_MEMORY(buf);
    355392        buf_ptr = buf;
    356393
     
    367404                        }
    368405                        *buf_ptr++ = '\\';
    369                 }
    370         }
     406                        talloc_free(tmp);
     407                }
     408        }
     409
     410        talloc_free(buf);
    371411
    372412        /* Add the key */
     
    379419                return error;
    380420        }
     421        talloc_free(tmp);
     422
    381423        return WERR_OK;
    382424}
     
    388430        /* We can't proof here for success, because a common superkey could */
    389431        /* have been deleted before the subkey's (diff order). This removed */
    390         /* therefore all childs recursively and the "WERR_BADFILE" result is */
     432        /* therefore all children recursively and the "WERR_BADFILE" result is */
    391433        /* expected. */
    392434
     
    420462        }
    421463
     464        talloc_free(tmp);
     465
    422466        return WERR_OK;
    423467}
     
    438482        }
    439483
    440         error = reg_del_value(tmp, value_name);
     484        error = reg_del_value(ctx, tmp, value_name);
    441485        if (!W_ERROR_IS_OK(error)) {
    442486                DEBUG(0, ("Error deleting value '%s'\n", value_name));
     
    444488        }
    445489
     490        talloc_free(tmp);
    446491
    447492        return WERR_OK;
     
    453498        struct registry_key *key;
    454499        WERROR error;
    455         const char* value_name;
     500        const char *value_name;
    456501
    457502        error = reg_open_key_abs(ctx, ctx, key_name, &key);
     
    467512        while (W_ERROR_IS_OK(reg_key_get_value_by_index(
    468513                        ctx, key, 0, &value_name, NULL, NULL))) {
    469                 error = reg_del_value(key, value_name);
     514                error = reg_del_value(ctx, key, value_name);
    470515                if (!W_ERROR_IS_OK(error)) {
    471516                        DEBUG(0, ("Error deleting value '%s'\n", value_name));
    472517                        return error;
    473518                }
    474         }
     519                talloc_free(discard_const_p(char, value_name));
     520        }
     521
     522        talloc_free(key);
    475523
    476524        return WERR_OK;
     
    481529 */
    482530_PUBLIC_ WERROR reg_diff_apply(struct registry_context *ctx,
    483                                                            struct smb_iconv_convenience *iconv_convenience,
    484531                                                           const char *filename)
    485532{
     
    493540        callbacks.done = NULL;
    494541
    495         return reg_diff_load(filename, iconv_convenience,
    496                              &callbacks, ctx);
    497 }
     542        return reg_diff_load(filename, &callbacks, ctx);
     543}
Note: See TracChangeset for help on using the changeset viewer.