Bug in MFDeploy WriteConfig

If you have ever tried to use MFDeploy WriteConfig to write custom configurations to your device, and gotten an exception, it is because there is a bug in the MFDeploy code. In certain cases, you will get an array index out of range exception.

I was using WriteConfig to write configuration parameters for the Scratch firmata engine and ran into this buffer overrun. I’ve submitted a pull request to github with the fix, and presuming I did the right fix, they should pull that into the 4.4 source tree. WriteConfig is useful for externally configuring your program with small bits of data like an id code for a board or small options, but the space is limited and it is not erased when you re-deploy your program. You have to use the MFDeploy app or library.

If you want to fix it yourself for a 4.3 app, you will need to change line 870 of MFConfigHelper.cs (4.3 QFE2 source) from:


to

```cs]byte[] temp = new byte[m_lastCfgIndex + data.Length >= m_all_cfg_data.Length ? m_lastCfgIndex + data.Length : m_all_cfg_data.Length];[/code


Luckily, you can make a private copy of all the files in the MFDeploy\Library directory in your own app, so this is a relatively easy fix.
4 Likes

Good catch :clap:

Please do not forget to report to Microsoft

is already on github … Fix array range exception during WriteConfig by martincalsyn · Pull Request #192 · NETMF/netmf-interpreter · GitHub

Kudos to Martin … :clap: :clap:

1 Like