mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-15 16:05:10 +01:00
*Moved every allocation of libntfs now to MEM2 (in mem1 it gets overwritten and so the games didn't work in last rev)
Forwarder change: *Ignore MBR partition type and read partition type from boot record sector (Channel will follow later)
This commit is contained in:
parent
9bcb476262
commit
85eb0a7ed2
@ -1082,7 +1082,7 @@ struct POSIX_SECURITY *ntfs_replace_acl(const struct POSIX_SECURITY *oldpxdesc,
|
||||
else
|
||||
newsize = sizeof(struct POSIX_SECURITY)
|
||||
+ (oldpxdesc->defcnt + count)*sizeof(struct POSIX_ACE);
|
||||
newpxdesc = (struct POSIX_SECURITY*)malloc(newsize);
|
||||
newpxdesc = (struct POSIX_SECURITY*)ntfs_malloc(newsize);
|
||||
if (newpxdesc) {
|
||||
if (deflt) {
|
||||
offset = oldpxdesc->acccnt;
|
||||
@ -1147,7 +1147,7 @@ struct POSIX_SECURITY *ntfs_build_inherited_posix(
|
||||
count = pxdesc->defcnt + 3;
|
||||
} else
|
||||
count = 3;
|
||||
pydesc = (struct POSIX_SECURITY*)malloc(
|
||||
pydesc = (struct POSIX_SECURITY*)ntfs_malloc(
|
||||
sizeof(struct POSIX_SECURITY) + count*sizeof(struct POSIX_ACE));
|
||||
if (pydesc) {
|
||||
/*
|
||||
@ -1330,7 +1330,7 @@ struct POSIX_SECURITY *ntfs_merge_descr_posix(const struct POSIX_SECURITY *first
|
||||
size = sizeof(struct POSIX_SECURITY)
|
||||
+ (first->acccnt + first->defcnt
|
||||
+ second->acccnt + second->defcnt)*sizeof(struct POSIX_ACE);
|
||||
pxdesc = (struct POSIX_SECURITY*)malloc(size);
|
||||
pxdesc = (struct POSIX_SECURITY*)ntfs_malloc(size);
|
||||
if (pxdesc) {
|
||||
/*
|
||||
* merge access ACEs
|
||||
@ -3490,7 +3490,7 @@ struct POSIX_SECURITY *ntfs_build_permissions_posix(
|
||||
* and 2 more for other
|
||||
*/
|
||||
alloccnt = acecnt + 6;
|
||||
pxdesc = (struct POSIX_SECURITY*)malloc(
|
||||
pxdesc = (struct POSIX_SECURITY*)ntfs_malloc(
|
||||
sizeof(struct POSIX_SECURITY)
|
||||
+ alloccnt*sizeof(struct POSIX_ACE));
|
||||
k = 0;
|
||||
|
@ -280,7 +280,7 @@ struct CACHED_GENERIC *ntfs_enter_cache(struct CACHE_HEADER *cache,
|
||||
cache->oldest_entry = current->previous;
|
||||
if (item->varsize) {
|
||||
if (current->varsize)
|
||||
current->variable = realloc(
|
||||
current->variable = MEM2_realloc(
|
||||
current->variable,
|
||||
item->varsize);
|
||||
else
|
||||
|
@ -267,7 +267,7 @@ static unsigned int ntfs_compress_block(const char *inbuf,
|
||||
unsigned int xout;
|
||||
unsigned int ntag;
|
||||
|
||||
pctx = (struct COMPRESS_CONTEXT*)malloc(sizeof(struct COMPRESS_CONTEXT));
|
||||
pctx = (struct COMPRESS_CONTEXT*)ntfs_malloc(sizeof(struct COMPRESS_CONTEXT));
|
||||
if (pctx) {
|
||||
pctx->inbuf = (const unsigned char*)inbuf;
|
||||
ntfs_init_compress_tree(pctx);
|
||||
|
@ -1257,7 +1257,7 @@ static int ntfs_ie_add_vcn(INDEX_ENTRY **ie)
|
||||
INDEX_ENTRY *p, *old = *ie;
|
||||
|
||||
old->length = cpu_to_le16(le16_to_cpu(old->length) + sizeof(VCN));
|
||||
p = realloc(old, le16_to_cpu(old->length));
|
||||
p = MEM2_realloc(old, le16_to_cpu(old->length));
|
||||
if (!p)
|
||||
return STATUS_ERROR;
|
||||
|
||||
|
@ -365,7 +365,7 @@ int ntfs_inode_real_close(ntfs_inode *ni)
|
||||
*/
|
||||
if (base_ni->nr_extents) {
|
||||
/* Resize the memory buffer. */
|
||||
tmp_nis = realloc(tmp_nis, base_ni->nr_extents *
|
||||
tmp_nis = MEM2_realloc(tmp_nis, base_ni->nr_extents *
|
||||
sizeof(ntfs_inode *));
|
||||
/* Ignore errors, they don't really matter. */
|
||||
if (tmp_nis)
|
||||
@ -1106,7 +1106,7 @@ int ntfs_inode_add_attrlist(ntfs_inode *ni)
|
||||
ctx->attr->name_length + 7) & ~7;
|
||||
al_len += ale_size;
|
||||
|
||||
aln = realloc(al, al_len);
|
||||
aln = MEM2_realloc(al, al_len);
|
||||
if (!aln) {
|
||||
err = errno;
|
||||
ntfs_log_perror("Failed to realloc %d bytes", al_len);
|
||||
|
@ -356,7 +356,7 @@ runlist *ntfs_cluster_alloc(ntfs_volume *vol, VCN start_vcn, s64 count,
|
||||
/* Reallocate memory if necessary. */
|
||||
if ((rlpos + 2) * (int)sizeof(runlist) >= rlsize) {
|
||||
rlsize += 4096;
|
||||
trl = realloc(rl, rlsize);
|
||||
trl = MEM2_realloc(rl, rlsize);
|
||||
if (!trl) {
|
||||
err = ENOMEM;
|
||||
ntfs_log_perror("realloc() failed");
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "types.h"
|
||||
#include "misc.h"
|
||||
#include "logging.h"
|
||||
#include "mem2.h"
|
||||
|
||||
/**
|
||||
* ntfs_calloc
|
||||
@ -44,7 +45,10 @@ void *ntfs_calloc(size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = calloc(1, size);
|
||||
p = MEM2_alloc(size);
|
||||
if(p)
|
||||
memset(p, 0, size);
|
||||
|
||||
if (!p)
|
||||
ntfs_log_perror("Failed to calloc %lld bytes", (long long)size);
|
||||
return p;
|
||||
@ -54,7 +58,7 @@ void *ntfs_malloc(size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = malloc(size);
|
||||
p = MEM2_alloc(size);
|
||||
if (!p)
|
||||
ntfs_log_perror("Failed to malloc %lld bytes", (long long)size);
|
||||
return p;
|
||||
|
@ -101,6 +101,7 @@ static void ntfs_rl_mc(runlist_element *dstbase, int dst,
|
||||
* On success, return a pointer to the newly allocated, or recycled, memory.
|
||||
* On error, return NULL with errno set to the error code.
|
||||
*/
|
||||
#include "mem2.h"
|
||||
static runlist_element *ntfs_rl_realloc(runlist_element *rl, int old_size,
|
||||
int new_size)
|
||||
{
|
||||
@ -108,7 +109,7 @@ static runlist_element *ntfs_rl_realloc(runlist_element *rl, int old_size,
|
||||
new_size = (new_size * sizeof(runlist_element) + 0xfff) & ~0xfff;
|
||||
if (old_size == new_size)
|
||||
return rl;
|
||||
return realloc(rl, new_size);
|
||||
return MEM2_realloc(rl, new_size);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -835,7 +836,7 @@ static runlist_element *ntfs_mapping_pairs_decompress_i(const ntfs_volume *vol,
|
||||
runlist_element *rl2;
|
||||
|
||||
rlsize += 0x1000;
|
||||
rl2 = realloc(rl, rlsize);
|
||||
rl2 = MEM2_realloc(rl, rlsize);
|
||||
if (!rl2) {
|
||||
int eo = errno;
|
||||
free(rl);
|
||||
|
@ -1554,7 +1554,7 @@ static struct CACHED_PERMISSIONS *enter_cache(struct SECURITY_CONTEXT *scx,
|
||||
if (pxdesc) {
|
||||
pxsize = sizeof(struct POSIX_SECURITY)
|
||||
+ (pxdesc->acccnt + pxdesc->defcnt)*sizeof(struct POSIX_ACE);
|
||||
pxcached = (struct POSIX_SECURITY*)malloc(pxsize);
|
||||
pxcached = (struct POSIX_SECURITY*)ntfs_malloc(pxsize);
|
||||
if (pxcached) {
|
||||
memcpy(pxcached, pxdesc, pxsize);
|
||||
cacheentry->pxdesc = pxcached;
|
||||
@ -1585,7 +1585,7 @@ static struct CACHED_PERMISSIONS *enter_cache(struct SECURITY_CONTEXT *scx,
|
||||
/* allocate block, if cache table was allocated */
|
||||
if (pcache && (index1 <= pcache->head.last)) {
|
||||
cacheblock = (struct CACHED_PERMISSIONS*)
|
||||
malloc(sizeof(struct CACHED_PERMISSIONS)
|
||||
ntfs_malloc(sizeof(struct CACHED_PERMISSIONS)
|
||||
<< CACHE_PERMISSIONS_BITS);
|
||||
pcache->cachetable[index1] = cacheblock;
|
||||
for (i=0; i<(1 << CACHE_PERMISSIONS_BITS); i++)
|
||||
@ -1598,7 +1598,7 @@ static struct CACHED_PERMISSIONS *enter_cache(struct SECURITY_CONTEXT *scx,
|
||||
if (pxdesc) {
|
||||
pxsize = sizeof(struct POSIX_SECURITY)
|
||||
+ (pxdesc->acccnt + pxdesc->defcnt)*sizeof(struct POSIX_ACE);
|
||||
pxcached = (struct POSIX_SECURITY*)malloc(pxsize);
|
||||
pxcached = (struct POSIX_SECURITY*)ntfs_malloc(pxsize);
|
||||
if (pxcached) {
|
||||
memcpy(pxcached, pxdesc, pxsize);
|
||||
cacheentry->pxdesc = pxcached;
|
||||
@ -3177,7 +3177,7 @@ int ntfs_set_mode(struct SECURITY_CONTEXT *scx, ntfs_inode *ni, mode_t mode)
|
||||
/* must copy before merging */
|
||||
pxsize = sizeof(struct POSIX_SECURITY)
|
||||
+ (oldpxdesc->acccnt + oldpxdesc->defcnt)*sizeof(struct POSIX_ACE);
|
||||
newpxdesc = (struct POSIX_SECURITY*)malloc(pxsize);
|
||||
newpxdesc = (struct POSIX_SECURITY*)ntfs_malloc(pxsize);
|
||||
if (newpxdesc) {
|
||||
memcpy(newpxdesc, oldpxdesc, pxsize);
|
||||
if (ntfs_merge_mode_posix(newpxdesc, mode))
|
||||
@ -3626,7 +3626,7 @@ int ntfs_set_ownmod(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
|
||||
/* must copy before merging */
|
||||
pxsize = sizeof(struct POSIX_SECURITY)
|
||||
+ (oldpxdesc->acccnt + oldpxdesc->defcnt)*sizeof(struct POSIX_ACE);
|
||||
newpxdesc = (struct POSIX_SECURITY*)malloc(pxsize);
|
||||
newpxdesc = (struct POSIX_SECURITY*)ntfs_malloc(pxsize);
|
||||
if (newpxdesc) {
|
||||
memcpy(newpxdesc, oldpxdesc, pxsize);
|
||||
if (ntfs_merge_mode_posix(newpxdesc, mode))
|
||||
@ -3891,7 +3891,7 @@ le32 ntfs_inherited_id(struct SECURITY_CONTEXT *scx,
|
||||
*
|
||||
* Returns 0 if OK, -1 (and errno set) if error
|
||||
*/
|
||||
|
||||
#include "mem2.h"
|
||||
static int link_single_group(struct MAPPING *usermapping, struct passwd *user,
|
||||
gid_t gid)
|
||||
{
|
||||
@ -3911,9 +3911,9 @@ static int link_single_group(struct MAPPING *usermapping, struct passwd *user,
|
||||
grmem++;
|
||||
if (*grmem) {
|
||||
if (!grcnt)
|
||||
groups = (gid_t*)malloc(sizeof(gid_t));
|
||||
groups = (gid_t*)ntfs_malloc(sizeof(gid_t));
|
||||
else
|
||||
groups = (gid_t*)realloc(groups,
|
||||
groups = (gid_t*)MEM2_realloc(groups,
|
||||
(grcnt+1)*sizeof(gid_t));
|
||||
if (groups)
|
||||
groups[grcnt++] = gid;
|
||||
|
@ -1013,7 +1013,7 @@ int ntfs_mbstoucs(const char *ins, ntfschar **outs)
|
||||
if (o >= ucs_len) {
|
||||
ntfschar *tc;
|
||||
ucs_len = (ucs_len * sizeof(ntfschar) + 64) & ~63;
|
||||
tc = realloc(ucs, ucs_len);
|
||||
tc = MEM2_realloc(ucs, ucs_len);
|
||||
if (!tc)
|
||||
goto err_out;
|
||||
ucs = tc;
|
||||
|
Loading…
Reference in New Issue
Block a user