Skip to content
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
12 changes: 12 additions & 0 deletions src/bin/getopts.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ int getopts_usage(char *progName, struct options opts[])
if (opts[count].name && opts[count].shortName)
{
cmd = calloc(1, strlen(opts[count].name) + strlen(opts[count].shortName) + 15);
if (!cmd)
{
return -1;
}
if (opts[count].args)
{
sprintf(cmd, "--%s,\t-%s <args>\t\t", opts[count].name, opts[count].shortName);
Expand All @@ -72,6 +76,10 @@ int getopts_usage(char *progName, struct options opts[])
else if (opts[count].name)
{
cmd = calloc(1, strlen(opts[count].name) + 15);
if (!cmd)
{
return -1;
}
if (opts[count].args)
{
sprintf(cmd, "--%s <args>\t\t\t", opts[count].name);
Expand All @@ -84,6 +92,10 @@ int getopts_usage(char *progName, struct options opts[])
else if (opts[count].shortName)
{
cmd = calloc(1, strlen(opts[count].shortName) + 15);
if (!cmd)
{
return -1;
}
if (opts[count].args)
{
sprintf(cmd, "\t\t-%s <args>\t\t", opts[count].shortName);
Expand Down
5 changes: 5 additions & 0 deletions src/libsmbios_c/cmos/cmos_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ LIBSMBIOS_C_DLL_SPEC struct cmos_access_obj *cmos_obj_factory(int flags, ...)
toReturn = &singleton;
else
toReturn = (struct cmos_access_obj *)calloc(1, sizeof(struct cmos_access_obj));
if (!toReturn){
return NULL;
}

if (toReturn->initialized)
goto out;
Expand Down Expand Up @@ -219,6 +222,8 @@ void cmos_obj_register_write_callback(struct cmos_access_obj *m, cmos_write_call

fnprintf(" allocate\n");
new = calloc(1, sizeof(struct callback));
if (!new)
return -1;
new->cb_fn = cb_fn;
new->userdata = userdata;
new->destructor = destructor;
Expand Down
3 changes: 3 additions & 0 deletions src/libsmbios_c/cmos/cmos_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ static void UT_cleanup(struct cmos_access_obj *this)
int init_cmos_struct_filename(struct cmos_access_obj *m, const char *fn)
{
struct ut_data *priv_ut = (struct ut_data *)calloc(1, sizeof(struct ut_data));
if (!priv_ut)
return -1;

priv_ut->filename = (char *)calloc(1, strlen(fn) + 1);
strcpy(priv_ut->filename, fn);

Expand Down
4 changes: 4 additions & 0 deletions src/libsmbios_c/memory/memory_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ struct memory_access_obj *memory_obj_factory(int flags, ...)
toReturn = &singleton;
else
toReturn = (struct memory_access_obj *)calloc(1, sizeof(struct memory_access_obj));
if (!toReturn)
return NULL;

if (toReturn->initialized)
goto out;
Expand Down Expand Up @@ -186,6 +188,8 @@ void memory_obj_free(struct memory_access_obj *m)
s64 memory_obj_search(const struct memory_access_obj *m, const char *pat, size_t patlen, u64 start, u64 end, u64 stride)
{
u8 *buf = calloc(1, patlen);
if (!buf)
goto err_out;
u64 cur = start;
int ret;
memory_obj_suggest_leave_open((struct memory_access_obj *)m);
Expand Down
2 changes: 2 additions & 0 deletions src/libsmbios_c/smbios/smbios_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ struct smbios_table *smbios_table_factory(int flags, ...)
toReturn = &singleton;
else
toReturn = (struct smbios_table *)calloc(1, sizeof(struct smbios_table));
if (!toReturn)
return NULL;

if (toReturn->initialized)
goto out;
Expand Down
2 changes: 2 additions & 0 deletions src/libsmbios_c/smi/smi_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ int __hidden LINUX_dell_smi_obj_execute(struct dell_smi_obj *this)
// allocate buffer
fnprintf(" allocate buffer: %zd\n", alloc_size);
buffer = calloc(1, alloc_size);
if(!buffer)
return -ENOMEM;
kernel_buf = (struct callintf_cmd *)buffer;

// LOCK
Expand Down
2 changes: 2 additions & 0 deletions src/libsmbios_c/system_info/property_tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ LIBSMBIOS_C_DLL_SPEC const char *sysinfo_get_property_ownership_tag()
buf[PROPERTY_TAG_LEN] = '\0'; // protect against potentially buggy BIOS (shouldnt ever be non-null)
strip_trailing_whitespace((char *)buf);
retval = calloc(1, strlen((char*)buf)+1); // dont see how these could ever overflow, let me know if I'm wrong. :)
if (!retval)
goto out_fail;
strcpy(retval, (const char*)buf);
fnprintf("tag: -->%s<--\n", retval);
goto out;
Expand Down
8 changes: 7 additions & 1 deletion src/libsmbios_c/system_info/service_tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ static char *getServiceTagFromCMOSToken()

// if we got a value, we have to allocate a larger buffer to hold the result
tag = calloc(1, SVC_TAG_LEN_MAX + 1);

if (!tag){
fnprintf("- out of memory\n");
tag = 0;
goto out;
}
// Step 2: Decode 7-char tag from 5-char CMOS value
fnprintf("- decode string\n");
dell_decode_service_tag(tag, tempval, len);
Expand Down Expand Up @@ -252,6 +256,8 @@ __hidden char *getTagFromSMI(u16 select)
goto out;

retval = calloc(1, MAX_SMI_TAG_SIZE + 1); // smi function can hold at most 12 bytes, add one for '\0'
if (!retval)
return -1;
memcpy(retval, (u8 *)(&(res[1])), MAX_SMI_TAG_SIZE);

fnprintf("raw = ");
Expand Down
4 changes: 4 additions & 0 deletions src/libsmbios_c/token/token_d4.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ int setup_d4_checksum(struct indexed_io_access_structure *d4_struct)
goto out;

d = calloc(1, sizeof(struct checksum_details));
if (!d){
fnprintf("out of memory\n");
goto out_err;
}

d->csumloc = d4_struct->checkValueIndex;
d->csumlen = sizeof(u16);
Expand Down
4 changes: 4 additions & 0 deletions src/libsmbios_c/token/token_da.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ static char * _da_get_string(const struct token_obj *t, size_t *len)
*len = 2;

retval = calloc(1, sizeof(u16));
if (!retval){
fnprintf("out of memory");
return -1;
}
memcpy(retval, &toRead, sizeof(u16));

out:
Expand Down
3 changes: 2 additions & 1 deletion src/libsmbios_c/token/token_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ struct token_table *token_table_factory(int flags, ...)
toReturn = &singleton;
else
toReturn = calloc(1, sizeof(struct token_table));

if (!toReturn)
return NULL;
if (toReturn->initialized)
goto out;

Expand Down