Skip to content

Commit

Permalink
Merge pull request #146 from hoene/issue-137-zero-attribute
Browse files Browse the repository at this point in the history
fixed issues 130, 132, 134 to 137
  • Loading branch information
hoene committed Nov 28, 2020
2 parents 251e02f + 0b250b6 commit bc59686
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Expand Up @@ -77,6 +77,11 @@ if(BUILD_TESTS)
82
83
84
130
132
135
136
137
138)
# issues with osx 96)
add_test(fail-issue-${ISSUE} ${PROJECT_SOURCE_DIR}/tests/notcrashed.sh
Expand Down
2 changes: 1 addition & 1 deletion src/hdf/btree.c
Expand Up @@ -266,7 +266,7 @@ int treeRead(struct READER *reader, struct DATAOBJECT *data) {

mylog("elements %d size %d\n", elements, size);

if (elements >= 0x100000 || size > 0x10)
if (elements <=0 || size <=0 || elements >= 0x100000 || size > 0x10)
return MYSOFA_INVALID_FORMAT; // LCOV_EXCL_LINE
if (!(output = malloc(elements * size))) {
return MYSOFA_NO_MEMORY; // LCOV_EXCL_LINE
Expand Down
2 changes: 1 addition & 1 deletion src/hdf/dataobject.c
Expand Up @@ -741,7 +741,7 @@ static int readOHDRHeaderMessageFilterPipeline(struct READER *reader) {
int readDataVar(struct READER *reader, struct DATAOBJECT *data,
struct DATATYPE *dt, struct DATASPACE *ds) {

char *buffer, number[16];
char *buffer, number[20];
uint64_t reference, gcol = 0, dataobject;
int err;
struct DATAOBJECT *referenceData;
Expand Down
3 changes: 2 additions & 1 deletion src/hdf/fractalhead.c
Expand Up @@ -196,7 +196,8 @@ static int directblockRead(struct READER *reader, struct DATAOBJECT *dataobject,

/* TODO: Get definition of this field */
unknown3 = readValue(reader, 2);
assert(unknown3 == 0x0000);
if(unknown3 != 0x0000)
return MYSOFA_INVALID_FORMAT;

len = fgetc(reader->fhd);
if (len < 0)
Expand Down
3 changes: 2 additions & 1 deletion src/hrtf/check.c
Expand Up @@ -160,7 +160,8 @@ MYSOFA_EXPORT int mysofa_check(struct MYSOFA_HRTF *hrtf) {
if (!verifyAttribute(hrtf->ReceiverPosition.attributes, "Type", "cartesian"))
return MYSOFA_RECEIVERS_WITH_CARTESIAN_SUPPORTED; // LCOV_EXCL_LINE

if (!fequals(hrtf->ReceiverPosition.values[0], 0.) ||
if (hrtf->ReceiverPosition.elements < 6 ||
!fequals(hrtf->ReceiverPosition.values[0], 0.) ||
!fequals(hrtf->ReceiverPosition.values[2], 0.) ||
!fequals(hrtf->ReceiverPosition.values[3], 0.) ||
!fequals(hrtf->ReceiverPosition.values[5], 0.)) {
Expand Down
2 changes: 1 addition & 1 deletion src/hrtf/tools.c
Expand Up @@ -34,7 +34,7 @@ int changeAttribute(struct MYSOFA_ATTRIBUTE *attr, char *name, char *value,
char *newvalue) {
while (attr) {
if (!strcmp(name, attr->name) &&
(value == NULL || !strcmp(value, attr->value))) {
(value == NULL || attr->value == NULL || !strcmp(value, attr->value))) {
free(attr->value);
attr->value = mysofa_strdup(newvalue);
return 1;
Expand Down
Binary file added tests/fail-issue-130.sofa
Binary file not shown.
Binary file added tests/fail-issue-132.sofa
Binary file not shown.
Binary file added tests/fail-issue-135.sofa
Binary file not shown.
Binary file added tests/fail-issue-136.sofa
Binary file not shown.
Binary file added tests/fail-issue-137.sofa
Binary file not shown.

0 comments on commit bc59686

Please sign in to comment.