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/dir.c

    r414 r745  
    4141
    4242        path = talloc_asprintf(mem_ctx, "%s/%s", dk->path, name);
     43        W_ERROR_HAVE_NO_MEMORY(path);
    4344        ret = mkdir(path, 0700);
    4445        if (ret == 0) {
    4546                struct dir_key *key = talloc(mem_ctx, struct dir_key);
     47                W_ERROR_HAVE_NO_MEMORY(key);
    4648                key->key.ops = &reg_backend_dir;
    4749                key->path = talloc_steal(key, path);
     
    7779
    7880                path = talloc_asprintf(name, "%s/%s", name, e->d_name);
    79                 if (!path)
    80                         return WERR_NOMEM;
     81                W_ERROR_HAVE_NO_MEMORY(path);
    8182
    8283                stat(path, &stbuf);
     
    109110}
    110111
    111 static WERROR reg_dir_del_key(const struct hive_key *k, const char *name)
     112static WERROR reg_dir_del_key(TALLOC_CTX *mem_ctx, const struct hive_key *k,
     113                              const char *name)
    112114{
    113115        struct dir_key *dk = talloc_get_type(k, struct dir_key);
    114         char *child = talloc_asprintf(NULL, "%s/%s", dk->path, name);
     116        char *child;
    115117        WERROR ret;
     118
     119        child = talloc_asprintf(mem_ctx, "%s/%s", dk->path, name);
     120        W_ERROR_HAVE_NO_MEMORY(child);
    116121
    117122        ret = reg_dir_delete_recursive(child);
     
    137142
    138143        fullpath = talloc_asprintf(mem_ctx, "%s/%s", p->path, name);
     144        W_ERROR_HAVE_NO_MEMORY(fullpath);
    139145
    140146        d = opendir(fullpath);
     
    142148                DEBUG(3,("Unable to open '%s': %s\n", fullpath,
    143149                        strerror(errno)));
     150                talloc_free(fullpath);
    144151                return WERR_BADFILE;
    145152        }
     
    160167        struct dirent *e;
    161168        const struct dir_key *dk = talloc_get_type(k, struct dir_key);
    162         int i = 0;
     169        unsigned int i = 0;
    163170        DIR *d;
    164171
     
    174181
    175182                        /* Check if file is a directory */
    176                         asprintf(&thispath, "%s/%s", dk->path, e->d_name);
     183                        thispath = talloc_asprintf(mem_ctx, "%s/%s", dk->path,
     184                                                   e->d_name);
     185                        W_ERROR_HAVE_NO_MEMORY(thispath);
    177186                        stat(thispath, &stbuf);
    178187
    179188                        if (!S_ISDIR(stbuf.st_mode)) {
    180                                 SAFE_FREE(thispath);
     189                                talloc_free(thispath);
    181190                                continue;
    182191                        }
     
    185194                                struct stat st;
    186195                                *name = talloc_strdup(mem_ctx, e->d_name);
     196                                W_ERROR_HAVE_NO_MEMORY(*name);
    187197                                *classname = NULL;
    188198                                stat(thispath, &st);
    189199                                unix_to_nt_time(last_mod_time, st.st_mtime);
    190                                 SAFE_FREE(thispath);
     200                                talloc_free(thispath);
    191201                                closedir(d);
    192202                                return WERR_OK;
     
    194204                        i++;
    195205
    196                         SAFE_FREE(thispath);
     206                        talloc_free(thispath);
    197207                }
    198208        }
     
    212222
    213223        dk = talloc(parent_ctx, struct dir_key);
     224        W_ERROR_HAVE_NO_MEMORY(dk);
    214225        dk->key.ops = &reg_backend_dir;
    215226        dk->path = talloc_strdup(dk, location);
     
    271282                        char *path = talloc_asprintf(ctx, "%s/%s",
    272283                                                     dk->path, e->d_name);
     284                        W_ERROR_HAVE_NO_MEMORY(path);
    273285
    274286                        if (stat(path, &st) < 0) {
    275287                                DEBUG(0, ("Error statting %s: %s\n", path,
    276288                                        strerror(errno)));
     289                                talloc_free(path);
    277290                                continue;
    278291                        }
     
    309322{
    310323        const struct dir_key *dk = talloc_get_type(key, struct dir_key);
    311         char *path = talloc_asprintf(dk, "%s/%s", dk->path, name);
    312 
    313         if (!file_save(path, data.data, data.length))
     324        char *path;
     325        bool ret;
     326
     327        path = talloc_asprintf(dk, "%s/%s", dk->path, name);
     328        W_ERROR_HAVE_NO_MEMORY(path);
     329
     330        ret = file_save(path, data.data, data.length);
     331
     332        talloc_free(path);
     333
     334        if (!ret) {
    314335                return WERR_GENERAL_FAILURE;
     336        }
    315337
    316338        /* FIXME: Type */
     
    324346{
    325347        const struct dir_key *dk = talloc_get_type(key, struct dir_key);
    326         char *path = talloc_asprintf(mem_ctx, "%s/%s", dk->path, name);
     348        char *path;
    327349        size_t size;
    328350        char *contents;
    329351
     352        path = talloc_asprintf(mem_ctx, "%s/%s", dk->path, name);
     353        W_ERROR_HAVE_NO_MEMORY(path);
     354
    330355        contents = file_load(path, &size, 0, mem_ctx);
     356
    331357        talloc_free(path);
     358
    332359        if (contents == NULL)
    333360                return WERR_BADFILE;
     
    343370
    344371static WERROR reg_dir_enum_value(TALLOC_CTX *mem_ctx,
    345                                  struct hive_key *key, int idx,
     372                                 struct hive_key *key, uint32_t idx,
    346373                                 const char **name,
    347374                                 uint32_t *type, DATA_BLOB *data)
     
    350377        DIR *d;
    351378        struct dirent *e;
    352         int i;
     379        unsigned int i;
    353380
    354381        d = opendir(dk->path);
     
    365392
    366393                if (i == idx) {
    367                         if (name != NULL)
     394                        if (name != NULL) {
    368395                                *name = talloc_strdup(mem_ctx, e->d_name);
     396                                W_ERROR_HAVE_NO_MEMORY(*name);
     397                        }
    369398                        W_ERROR_NOT_OK_RETURN(reg_dir_get_value(mem_ctx, key,
    370399                                                                *name, type,
     
    381410
    382411
    383 static WERROR reg_dir_del_value (struct hive_key *key, const char *name)
     412static WERROR reg_dir_del_value(TALLOC_CTX *mem_ctx,
     413                                struct hive_key *key, const char *name)
    384414{
    385415        const struct dir_key *dk = talloc_get_type(key, struct dir_key);
    386         char *path = talloc_asprintf(key, "%s/%s", dk->path, name);
    387         if (unlink(path) < 0) {
    388                 talloc_free(path);
     416        char *path;
     417        int ret;
     418
     419        path = talloc_asprintf(mem_ctx, "%s/%s", dk->path, name);
     420        W_ERROR_HAVE_NO_MEMORY(path);
     421
     422        ret = unlink(path);
     423
     424        talloc_free(path);
     425
     426        if (ret < 0) {
    389427                if (errno == ENOENT)
    390428                        return WERR_BADFILE;
    391429                return WERR_GENERAL_FAILURE;
    392430        }
    393         talloc_free(path);
    394431
    395432        return WERR_OK;
Note: See TracChangeset for help on using the changeset viewer.