Skip to content

Commit 6ccbbba

Browse files
committed
Remove unused and broken HIDPowerDevice_::sendDate method
The method currently uses a local bval variable as argument when calling HID().SendReport(...). This is problematic, since the SendReport method doesn't use bval immediately. It instead captures a pointer to bval which is accessed when the report is sent at a later point. This leads to a use-after-free situation when the pointer captured by SendReport no longer point to bval, but some other unknown data.
1 parent cef7b0d commit 6ccbbba

File tree

2 files changed

+0
-6
lines changed

2 files changed

+0
-6
lines changed

src/HIDPowerDevice.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,6 @@ void HIDPowerDevice_::setSerial(const char* s) {
249249
void HIDPowerDevice_::end(void) {
250250
}
251251

252-
int HIDPowerDevice_::sendDate(uint16_t id, uint16_t year, uint8_t month, uint8_t day) {
253-
uint16_t bval = (year - 1980)*512 + month * 32 + day;
254-
return HID().SendReport(id, &bval, sizeof (bval));
255-
}
256-
257252
int HIDPowerDevice_::sendReport(uint16_t id, const void* bval, int len) {
258253
return HID().SendReport(id, bval, len);
259254
}

src/HIDPowerDevice.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ class HIDPowerDevice_ {
121121

122122
void end(void);
123123

124-
int sendDate(uint16_t id, uint16_t year, uint8_t month, uint8_t day);
125124
int sendReport(uint16_t id, const void* bval, int len);
126125

127126
int setFeature(uint16_t id, const void* data, int len);

0 commit comments

Comments
 (0)