Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: some unchecked possible nullptr #138

Open
wants to merge 1 commit into
base: edge
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libntfs-3g/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,8 @@ static INDEX_ENTRY *ntfs_index_walk_down(INDEX_ENTRY *ie,

ictx->ir = (INDEX_ROOT*)NULL;
ictx->ib = (INDEX_BLOCK*)ntfs_malloc(ictx->block_size);
if (!ictx->ib)
return NULL;
ictx->pindex = 1;
ictx->is_in_root = FALSE;
} else {
Expand Down
2 changes: 2 additions & 0 deletions libntfs-3g/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,8 @@ static struct CACHED_PERMISSIONS *enter_cache(struct SECURITY_CONTEXT *scx,
cacheblock = (struct CACHED_PERMISSIONS*)
malloc(sizeof(struct CACHED_PERMISSIONS)
<< CACHE_PERMISSIONS_BITS);
if (!cacheblock)
return NULL;
pcache->cachetable[index1] = cacheblock;
for (i=0; i<(1 << CACHE_PERMISSIONS_BITS); i++)
cacheblock[i].valid = 0;
Expand Down
10 changes: 10 additions & 0 deletions ntfsprogs/ntfsrecover.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ struct ATTR *getattrentry(unsigned int key, unsigned int lth)
} else {
attrtable = (struct ATTR**)
malloc(sizeof(struct ATTR*));
if (!attrtable){
free(pa);
return NULL;
}
attrtable[0] = pa;
}
pa->key = key;
Expand Down Expand Up @@ -349,6 +353,8 @@ static const struct BUFFER *read_buffer(CONTEXT *ctx, unsigned int num)
if (!buffer) {
buffer = (struct BUFFER*)
malloc(sizeof(struct BUFFER) + blocksz);
if (!buffer)
return NULL;
buffer->size = blocksz;
buffer->rnum = num + 1; /* forced to being read */
buffer->safe = FALSE;
Expand Down Expand Up @@ -2474,6 +2480,8 @@ static u16 overlapshow(CONTEXT *ctx, u16 k, u32 blk, const struct BUFFER *buf,
if ((space >= LOG_RECORD_HEAD_SZ)
&& (size > space)) {
fullrec = (char*)malloc(size);
if (!fullrec)
return 0;
if (size <= (space + nextspace)) {
/* Overlap on two blocks */
memcpy(fullrec,&data[k],space);
Expand Down Expand Up @@ -3356,6 +3364,8 @@ static TRISTATE backoverlap(CONTEXT *ctx, int blk,
&& (size > space)
&& (size < MAXRECSIZE)) {
fullrec = (char*)malloc(size);
if (!fullrec)
return T_ERR;
memcpy(fullrec,&data[k],space);
if (size <= (space + nextspace))
memcpy(&fullrec[space], nextdata + blkheadsz,
Expand Down
4 changes: 4 additions & 0 deletions ntfsprogs/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,10 @@ struct mft_search_ctx * mft_get_search_ctx(ntfs_volume *vol)
}

ctx = (struct mft_search_ctx*)calloc(1, sizeof *ctx);
if(!ctx){
errno = ENOMEM;
return NULL;
}

ctx->mft_num = -1;
ctx->vol = vol;
Expand Down