Skip to content

wTrig.getVersion() array overrun Issue #28

@KieranReck

Description

@KieranReck

ISSUE
Using the wTrig.getVersion() function as outlined in the WTrigAdvanced.ino example sketch causes an array overrun within the gWTrigVersion char array. This causes your arduino sketch to get stuck in a reset loop within the setup() function.

STEPS TO RECREATE
Run the WTrigAdvanced example file but with an empty loop() function. You will see that the sketch never prints the firmware version, number of tracks, or "WAV Trigger response not available" over the serial monitor and instead gets stuck resetting the setup() function. (the attached .txt sketch can be used to recreate the issue)
WTrigAdvanced(current).txt

PROPOSED FIX
In the wavTrigger.cpp file, modify line 236.

Current:
pDst[++i] = 0;

Proposed:
pDst[i] = 0;

The overrun is occurring because when the FOR loop reaches its break condition, i = VERSION_STRING_LEN - 1. This is the maximum boundary of "char gWTrigVersion[VERSION_STRING_LEN]" so incrementing i again before adding the zero character takes it beyond bounds.

From my testing, this proposed fix appears to work well, but this is my first time venturing into .cpp and .h files so please don't take my word for it. Also, sorry if this issue report isn't formatted correctly, I have never submitted one before. Thanks for all of the hard work your done so far on this library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions