Skip to content

Commit 41764e1

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 0801b11 commit 41764e1

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
@@ -250,11 +250,6 @@ void HIDPowerDevice_::setSerial(const char* s) {
250250
void HIDPowerDevice_::end(void) {
251251
}
252252

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

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)