mirror of
https://github.com/MatMoul/g810-led.git
synced 2024-12-23 09:16:11 +00:00
Possible buffer overflow correction
This commit is contained in:
parent
a4a0b83542
commit
4f9b5f381b
@ -672,31 +672,36 @@ bool Keyboard::setKey(Key key, KeyColors colors) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
|
bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
|
||||||
KeyValue logo[5];
|
int maxLogoKeys = 5;
|
||||||
int logoCount = 0;
|
int logoCount = 0;
|
||||||
KeyValue indicators[25];
|
KeyValue logo[maxLogoKeys];
|
||||||
|
int maxIndicatorsKeys = 25;
|
||||||
int indicatorsCount = 0;
|
int indicatorsCount = 0;
|
||||||
KeyValue multimedia[25];
|
KeyValue indicators[maxIndicatorsKeys];
|
||||||
|
int maxMultimediaKeys = 25;
|
||||||
int multimediaCount = 0;
|
int multimediaCount = 0;
|
||||||
KeyValue keys[200];
|
KeyValue multimedia[maxMultimediaKeys];
|
||||||
|
int maxKeys = 200;
|
||||||
int keysCount = 0;
|
int keysCount = 0;
|
||||||
KeyValue gkeys[25];
|
KeyValue keys[maxKeys];
|
||||||
|
int maxGKeys = 25;
|
||||||
int gkeysCount = 0;
|
int gkeysCount = 0;
|
||||||
|
KeyValue gkeys[maxGKeys];
|
||||||
|
|
||||||
for (int i = 0; i < keyValueCount; i++) {
|
for (int i = 0; i < keyValueCount; i++) {
|
||||||
if(keyValue[i].key.addressGroup == KeyAddressGroup::logo) {
|
if(keyValue[i].key.addressGroup == KeyAddressGroup::logo && logoCount <= maxLogoKeys) {
|
||||||
logo[logoCount] = keyValue[i];
|
logo[logoCount] = keyValue[i];
|
||||||
logoCount++;
|
logoCount++;
|
||||||
} else if(keyValue[i].key.addressGroup == KeyAddressGroup::indicators) {
|
} else if(keyValue[i].key.addressGroup == KeyAddressGroup::indicators && logoCount <= maxIndicatorsKeys) {
|
||||||
indicators[indicatorsCount] = keyValue[i];
|
indicators[indicatorsCount] = keyValue[i];
|
||||||
indicatorsCount++;
|
indicatorsCount++;
|
||||||
} else if(keyValue[i].key.addressGroup == KeyAddressGroup::multimedia) {
|
} else if(keyValue[i].key.addressGroup == KeyAddressGroup::multimedia && logoCount <= maxMultimediaKeys) {
|
||||||
multimedia[multimediaCount] = keyValue[i];
|
multimedia[multimediaCount] = keyValue[i];
|
||||||
multimediaCount++;
|
multimediaCount++;
|
||||||
} else if(keyValue[i].key.addressGroup == KeyAddressGroup::keys) {
|
} else if(keyValue[i].key.addressGroup == KeyAddressGroup::keys && logoCount <= maxKeys) {
|
||||||
keys[keysCount] = keyValue[i];
|
keys[keysCount] = keyValue[i];
|
||||||
keysCount++;
|
keysCount++;
|
||||||
} else if(keyValue[i].key.addressGroup == KeyAddressGroup::gkeys) {
|
} else if(keyValue[i].key.addressGroup == KeyAddressGroup::gkeys && logoCount <= maxGKeys) {
|
||||||
gkeys[gkeysCount] = keyValue[i];
|
gkeys[gkeysCount] = keyValue[i];
|
||||||
gkeysCount++;
|
gkeysCount++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user