Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit d41dd6b

Browse files
author
Martin Calsyn
committed
Fix array range exception during WriteConfig
In WriteConfig at line 878, a temp buffer is allocated at line 878 to include the current config plus the addition. When the length of the current config plus the new data is larger than the current size of the m_cfg_all_data array, the temp array should be enlarged to accomodate the new data. In the existing code, the allocation uses m_lastCfgInd instead of m_lastCfgIndex+data.Length and so under-allocates space when m_lastCfgIndex+data.Length would exceed the current size of m_all_cfg_data.Length. This fix corrects the under-allocation and resulting exception on line 881.
1 parent 8d1e5cf commit d41dd6b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Framework/Tools/MFDeploy/Library/MFConfigHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ private void WriteConfig(string configName, byte[] data, bool staticSize, bool u
875875
newLastIndex++; // Force a 4 byte boundary
876876
}
877877

878-
byte[] temp = new byte[m_lastCfgIndex >= m_all_cfg_data.Length ? m_lastCfgIndex + data.Length : m_all_cfg_data.Length];
878+
byte[] temp = new byte[m_lastCfgIndex + data.Length >= m_all_cfg_data.Length ? m_lastCfgIndex + data.Length : m_all_cfg_data.Length];
879879

880880
Array.Copy(m_all_cfg_data, 0, temp, 0, m_all_cfg_data.Length);
881881
Array.Copy( data, 0, temp, m_lastCfgIndex, data.Length);

0 commit comments

Comments
 (0)