Berry Hue fix regression from #23429 (#23623)

This commit is contained in:
s-hadinger 2025-06-30 20:34:51 +02:00 committed by GitHub
parent 550b8c5307
commit 143cfdd4f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 4 deletions

View File

@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
- Berry vulnerability in JSON parsing for unicode
- Berry fix security issues in `int64` and improve documentation
- Berry fix security issues in `berry_mapping` and improve documentation
- Berry Hue fix regression from #23429
### Removed

View File

@ -51,8 +51,9 @@ bool be_hue_status(String* response, uint32_t device_id) {
return handled;
}
// AddLog(LOG_LEVEL_DEBUG_MORE, ">be_hue_status response='%s' device_id=%i", response->c_str(), device_id);
be_pop(vm, 1);
}
be_pop(vm, 2);
be_pop(vm, 1);
return false;
}
@ -70,6 +71,7 @@ void be_hue_discovery(String* response, bool* appending) {
int32_t ret = be_pcall(vm, 1); // 2 params: self
if (ret != 0) {
be_error_pop_all(vm); // clear Berry stack
return;
}
be_pop(vm, 1);
if (be_isstring(vm, -1)) {
@ -81,8 +83,9 @@ void be_hue_discovery(String* response, bool* appending) {
}
}
// AddLog(LOG_LEVEL_DEBUG_MORE, ">be_hue_discovery");
be_pop(vm, 1);
}
be_pop(vm, 2);
be_pop(vm, 1);
}
// Groups command, list all ids prefixed by ',', ex: ",11,23"
@ -98,6 +101,7 @@ void be_hue_groups(String* response) {
int32_t ret = be_pcall(vm, 1); // 2 params: self
if (ret != 0) {
be_error_pop_all(vm); // clear Berry stack
return;
}
be_pop(vm, 1);
if (be_isstring(vm, -1)) {
@ -106,8 +110,9 @@ void be_hue_groups(String* response) {
*response += buf;
}
}
be_pop(vm, 1);
}
be_pop(vm, 2);
be_pop(vm, 1);
}
// handle incoming command
@ -130,6 +135,7 @@ bool be_hue_command(uint8_t device, uint32_t device_id, String* response) {
int32_t ret = be_pcall(vm, 3); // 2 params: self, id, args
if (ret != 0) {
be_error_pop_all(vm); // clear Berry stack
return false;
}
be_pop(vm, 3);
if (be_isstring(vm, -1)) {
@ -141,8 +147,9 @@ bool be_hue_command(uint8_t device, uint32_t device_id, String* response) {
return handled;
}
// AddLog(LOG_LEVEL_DEBUG_MORE, ">be_hue_status response='%s' device_id=%i", response->c_str(), device_id);
be_pop(vm, 1);
}
be_pop(vm, 2);
be_pop(vm, 1);
return false;
}

View File

@ -80,6 +80,10 @@ const char be_berry_init_code[] =
"import light "
#endif // USE_LIGHT
#if defined(USE_EMULATION) && defined(USE_EMULATION_HUE)
"import hue_bridge "
#endif
"do import tapp end " // we don't need to keep `tapp` in the global namespace
#ifdef USE_BERRY_DEBUG