Changeset 2237

Show
Ignore:
Timestamp:
09/29/12 06:09:55 (12 years ago)
Author:
jwoithe
Message:

dice: saffire pro40: a test to see whether ticket #362 is caused by a lack of null-termination of the returned nickname. If so, this fix is likely to be needed by other saffire sub-drivers too.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/dice/focusrite/saffire_pro40.cpp

    r2220 r2237  
    282282 
    283283bool SaffirePro40::setNickname(std::string name) { 
    284     return getEAP()->writeRegBlock(Dice::EAP::eRT_Application, 0x44, (quadlet_t*)name.c_str(), name.size()); 
     284    signed int len = name.size(); 
     285    // The device has room for at most 16 characters 
     286    if (len > 16) 
     287      len = 16; 
     288    return getEAP()->writeRegBlock(Dice::EAP::eRT_Application, 0x44, (quadlet_t*)name.c_str(), len); 
    285289} 
    286290std::string SaffirePro40::getNickname() { 
    287     char name[16]; 
     291    char name[20]; 
    288292    getEAP()->readRegBlock(Dice::EAP::eRT_Application, 0x44, (quadlet_t*)name, 16); 
     293    // The device supplies at most 16 characters.  Ensure the string is 
     294    // NULL terminated. 
     295    name[16] = 0; 
    289296    return std::string(name); 
    290297}