Skip to content

Commit

Permalink
Limit maximum switches to 200 to prevent crash with Olympus camera
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Oct 7, 2023
1 parent 7e54b35 commit 14b472d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions indi-gphoto/gphoto_ccd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,8 @@ bool GPhotoCCD::ISNewText(const char * dev, const char * name, char * texts[], c
return false;
char *text = texts[0];
char buf[256];
if(strcmp("eoszoomposition", name) == 0) {
if(strcmp("eoszoomposition", name) == 0)
{
int x = 0, y = 0;
LOGF_DEBUG("%s %s", name, text);
sscanf(text, "%d,%d", &x, &y);
Expand Down Expand Up @@ -1569,7 +1570,7 @@ void GPhotoCCD::AddWidget(gphoto_widget * widget)
{
IPerm perm;

if (!widget)
if (!widget || ((widget->type == GP_WIDGET_RADIO || widget->type == GP_WIDGET_MENU) && widget->choice_cnt > MAX_SWITCHES))
return;

perm = widget->readonly ? IP_RO : IP_RW;
Expand Down
2 changes: 2 additions & 0 deletions indi-gphoto/gphoto_ccd.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ class GPhotoCCD : public INDI::CCD, public INDI::FocuserInterface
static constexpr double FOCUS_HIGH_MED_RATIO = 7.33;
// Ratio from far 2 to far 1
static constexpr double FOCUS_MED_LOW_RATIO = 6.36;
// Do not accept switches more than this
static constexpr uint8_t MAX_SWITCHES = 200;

friend void ::ISSnoopDevice(XMLEle * root);
friend void ::ISGetProperties(const char * dev);
Expand Down

0 comments on commit 14b472d

Please sign in to comment.