CSync: Remove memory checks

We will get OOMed before this fails.
This commit is contained in:
Markus Goetz 2015-01-23 16:58:57 +01:00
parent a999884adf
commit af9daaeff7
9 changed files with 0 additions and 53 deletions

View file

@ -103,11 +103,6 @@ int csync_exclude_load(const char *fname, c_strlist_t **list) {
goto out;
}
buf = c_malloc(size + 1);
if (buf == NULL) {
rc = -1;
goto out;
}
if (read(fd, buf, size) != size) {
rc = -1;
goto out;

View file

@ -251,9 +251,6 @@ static int _csync_file_stat_from_metadata_table( csync_file_stat_t **st, sqlite3
/* phash, pathlen, path, inode, uid, gid, mode, modtime */
len = sqlite3_column_int(stmt, 1);
*st = c_malloc(sizeof(csync_file_stat_t) + len + 1);
if (*st == NULL) {
return SQLITE_NOMEM;
}
/* clear the whole structure */
ZERO_STRUCTP(*st);

View file

@ -201,10 +201,6 @@ static int _csync_detect_update(CSYNC *ctx, const char *file,
size = sizeof(csync_file_stat_t) + len + 1;
st = c_malloc(size);
if (st == NULL) {
ctx->status_code = CSYNC_STATUS_MEMORY_ERROR;
return -1;
}
/* Set instruction by default to none */
st->instruction = CSYNC_INSTRUCTION_NONE;

View file

@ -260,9 +260,6 @@ static char* get_transfer_url( hbf_transfer_t *transfer, int indx ) {
len += strlen("-chunking---");
res = malloc(len);
if( res == NULL ) {
return NULL;
}
/* Note: must be %u for unsigned because one does not want '--' */
if( sprintf(res, "%s-chunking-%u-%u-%u", transfer->url, transfer->transfer_id,

View file

@ -179,9 +179,6 @@ c_list_t *c_list_alloc(void) {
c_list_t *list = NULL;
list = c_malloc(sizeof(c_list_t));
if (list == NULL) {
return NULL;
}
list->data = NULL;

View file

@ -67,9 +67,6 @@ char *c_dirname (const char *path) {
while(len > 0 && path[len - 1] == '/') --len;
newbuf = c_malloc(len + 1);
if (newbuf == NULL) {
return NULL;
}
strncpy(newbuf, path, len);
newbuf[len] = '\0';
@ -107,9 +104,6 @@ char *c_basename (const char *path) {
}
newbuf = c_malloc(len + 1);
if (newbuf == NULL) {
return NULL;
}
strncpy(newbuf, s, len);
newbuf[len] = '\0';

View file

@ -47,10 +47,6 @@ int c_rbtree_create(c_rbtree_t **rbtree, c_rbtree_compare_func *key_compare, c_r
}
tree = c_malloc(sizeof(*tree));
if (tree == NULL) {
return -1;
}
tree->root = NIL;
tree->key_compare = key_compare;
tree->data_compare = data_compare;
@ -400,10 +396,6 @@ int c_rbtree_insert(c_rbtree_t *tree, void *data) {
}
x = (c_rbnode_t *) c_malloc(sizeof(c_rbnode_t));
if (x == NULL) {
errno = ENOMEM;
return -1;
}
x->tree = tree;
x->data = data;

View file

@ -115,10 +115,6 @@ static char *c_iconv(const char* str, enum iconv_direction dir)
out = c_malloc(outsize);
out_in = out;
if (out == NULL) {
return NULL;
}
if (dir == iconv_to_native) {
ret = iconv(_iconvs.to, &in, &size, &out, &outsize);
} else {
@ -173,10 +169,6 @@ c_strlist_t *c_strlist_new(size_t size) {
}
strlist->vector = (char **) c_malloc(size * sizeof(char *));
if (strlist->vector == NULL) {
SAFE_FREE(strlist);
return NULL;
}
strlist->count = 0;
strlist->size = size;
@ -267,10 +259,6 @@ char* c_utf8_from_locale(const mbchar_t *wstr)
size_needed = WideCharToMultiByte(CP_UTF8, 0, wstr, len, NULL, 0, NULL, NULL);
if (size_needed > 0) {
mdst = c_malloc(size_needed + 1);
if (mdst == NULL) {
errno = ENOMEM;
return NULL;
}
memset(mdst, 0, size_needed + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, len, mdst, size_needed, NULL, NULL);
@ -305,11 +293,6 @@ mbchar_t* c_utf8_to_locale(const char *str)
if (size_needed > 0) {
int size_char = (size_needed + 1) * sizeof(mbchar_t);
dst = c_malloc(size_char);
if (dst == NULL) {
errno = ENOMEM;
return NULL;
}
memset((void*)dst, 0, size_char);
MultiByteToWideChar(CP_UTF8, 0, str, -1, dst, size_needed);
}

View file

@ -53,10 +53,6 @@ csync_vio_handle_t *csync_vio_local_opendir(const char *name) {
mbchar_t *dirname = c_utf8_to_locale(name);
handle = c_malloc(sizeof(dhandle_t));
if (handle == NULL) {
c_free_locale_string(dirname);
return NULL;
}
handle->dh = _topendir( dirname );
if (handle->dh == NULL) {