Ignore:
Timestamp:
09/12/17 11:26:33 (4 years ago)
Author:
Sanahuja Guillaume
Message:

avoid buffer overrun

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/NeoM8N.cpp

    r195 r196  
    4242
    4343void NeoM8N::Run(void) {
    44   char response[200] = {0};
    45   int size,written;
    46 
    47   //turn off all mesages
     44 
     45  //turn off all messages
    4846  {
    4947    char tx[]={0x06, 0x01, 0x03, 0, 0xf0, 0,0};
     
    8280 
    8381  while (!ToBeStopped()) {
    84     //SleepMS(10);??
    85     size = 0;
     82    char response[1024] = {0};
     83    int size = 0;
    8684    while (!ToBeStopped()) {
    8785      ssize_t read = serialport->Read(&response[size], 1);
     
    9088      }
    9189
    92       if (response[size] == 0x0a)
    93         break;
     90      if (response[size] == 0x0a ) break;
    9491      size++;
     92      if (size==sizeof(response)) break;
    9593    }
    96     size++;
    97     parseFrame(response, size);
     94    if (size!=sizeof(response)) {
     95      size++;
     96      parseFrame(response, size);
     97    } else {
     98      Thread::Warn("frame too long for buffer\n");
     99    }
    98100  }
    99101  /** fin running loop **/
Note: See TracChangeset for help on using the changeset viewer.