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

[spot] fix heap-buffer-overflow #1186

Merged
merged 1 commit into from
Jul 15, 2020
Merged
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
14 changes: 9 additions & 5 deletions c/spot/source/tto.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,11 @@ static void dumpFeatureParams(FeatureRecord *record, Feature *feature, IntX leve
if (lastFeatureParam->param != NULL) {
/* Skip printing the param block if we have already printed it. */
char *cp = (char *)&record->FeatureTag;
char *pp = (char *)&lastFeatureParam->featTag;

if (record->FeatureTag == TAG('s', 'i', 'z', 'e')) {
if ((0 == memcmp(lastFeatureParam->param, (char *)FeatureParam, 10)) && (record->FeatureTag == lastFeatureParam->featTag)) {
if ((record->FeatureTag == lastFeatureParam->featTag) &&
(0 == memcmp(lastFeatureParam->param, (char *)FeatureParam, 10))) {
if ((level == 7) || (level < 5)) {
if ((currentLang == 0) && (currentScript == 0)) {
fprintf(OUTPUTBUFF, "\n# Skipping optical size parameter block in feature '%c%c%c%c' offset %04hx. It was previously reported for feature '%c%c%c%c' offset %04hx.\n",
Expand All @@ -351,8 +353,9 @@ static void dumpFeatureParams(FeatureRecord *record, Feature *feature, IntX leve
}
} else if ((cp[3] == 's') &&
(cp[2] == 's')) {
if ((0 == memcmp(lastFeatureParam->param, (char *)FeatureParam, 4)) && (cp[3] == 's') && (cp[2] == 's'))

if ((pp[3] == 's') &&
(pp[2] == 's') &&
(0 == memcmp(lastFeatureParam->param, (char *)FeatureParam, 4)))
{
if ((level == 7) || (level < 5)) {
if ((currentLang == 0) && (currentScript == 0)) {
Expand All @@ -369,8 +372,9 @@ static void dumpFeatureParams(FeatureRecord *record, Feature *feature, IntX leve
}
} else if ((cp[3] == 'c') &&
(cp[2] == 'v')) {
if ((0 == memcmp(lastFeatureParam->param, (char *)FeatureParam, 14)) && (cp[3] == 'c') && (cp[2] == 'v'))

if ((pp[3] == 'c') &&
(pp[2] == 'v') &&
(0 == memcmp(lastFeatureParam->param, (char *)FeatureParam, 14)))
{
if ((level == 7) || (level < 5)) {
if ((currentLang == 0) && (currentScript == 0)) {
Expand Down