Browse Source

Fix potential name conflict with strncpy

Signed-off-by: falkTX <falktx@falktx.com>
pull/397/head
falkTX 2 years ago
parent
commit
52536b96c5
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 45 additions and 47 deletions
  1. +10
    -12
      distrho/src/DistrhoPluginCLAP.cpp
  2. +1
    -1
      distrho/src/DistrhoPluginInternal.hpp
  3. +18
    -18
      distrho/src/DistrhoPluginVST2.cpp
  4. +16
    -16
      distrho/src/DistrhoPluginVST3.cpp

+ 10
- 12
distrho/src/DistrhoPluginCLAP.cpp View File

@@ -1129,7 +1129,7 @@ public:
if (hints & (kParameterIsBoolean|kParameterIsInteger))
info->flags |= CLAP_PARAM_IS_STEPPED;

DISTRHO_NAMESPACE::strncpy(info->name, fPlugin.getParameterName(index), CLAP_NAME_SIZE);
d_strncpy(info->name, fPlugin.getParameterName(index), CLAP_NAME_SIZE);

uint wrtn;
if (groupId != kPortGroupNone)
@@ -1145,7 +1145,7 @@ public:
wrtn = 0;
}

DISTRHO_NAMESPACE::strncpy(info->module + wrtn, fPlugin.getParameterSymbol(index), CLAP_PATH_SIZE - wrtn);
d_strncpy(info->module + wrtn, fPlugin.getParameterSymbol(index), CLAP_PATH_SIZE - wrtn);
}

info->id = index;
@@ -1182,7 +1182,7 @@ public:
{
if (d_isEqual(static_cast<double>(enumValues.values[i].value), value))
{
DISTRHO_NAMESPACE::strncpy(display, enumValues.values[i].label, size);
d_strncpy(display, enumValues.values[i].label, size);
return true;
}
}
@@ -1328,7 +1328,7 @@ public:
const BusInfo& busInfo(busInfos[index]);

info->id = busInfo.groupId;
DISTRHO_NAMESPACE::strncpy(info->name, busInfo.name, CLAP_NAME_SIZE);
d_strncpy(info->name, busInfo.name, CLAP_NAME_SIZE);

info->flags = busInfo.isMain ? CLAP_AUDIO_PORT_IS_MAIN : 0x0;
info->channel_count = busInfo.numChannels;
@@ -1893,16 +1893,15 @@ private:
case kPortGroupMono:
if (busInfo.isMain)
{
DISTRHO_NAMESPACE::strncpy(busInfo.name,
isInput ? "Audio Input" : "Audio Output", CLAP_NAME_SIZE);
d_strncpy(busInfo.name, isInput ? "Audio Input" : "Audio Output", CLAP_NAME_SIZE);
break;
}
// fall-through
default:
if (group.name.isNotEmpty())
DISTRHO_NAMESPACE::strncpy(busInfo.name, group.name, CLAP_NAME_SIZE);
d_strncpy(busInfo.name, group.name, CLAP_NAME_SIZE);
else
DISTRHO_NAMESPACE::strncpy(busInfo.name, port.name, CLAP_NAME_SIZE);
d_strncpy(busInfo.name, port.name, CLAP_NAME_SIZE);
break;
}

@@ -1935,7 +1934,7 @@ private:
nonGroupSidechainId++
};

DISTRHO_NAMESPACE::strncpy(busInfo.name, port.name, CLAP_NAME_SIZE);
d_strncpy(busInfo.name, port.name, CLAP_NAME_SIZE);

busInfos.push_back(busInfo);
}
@@ -1961,12 +1960,11 @@ private:

if (busInfo.isMain)
{
DISTRHO_NAMESPACE::strncpy(busInfo.name,
isInput ? "Audio Input" : "Audio Output", CLAP_NAME_SIZE);
d_strncpy(busInfo.name, isInput ? "Audio Input" : "Audio Output", CLAP_NAME_SIZE);
}
else
{
DISTRHO_NAMESPACE::strncpy(busInfo.name, port.name, CLAP_NAME_SIZE);
d_strncpy(busInfo.name, port.name, CLAP_NAME_SIZE);
}

busInfos.push_back(busInfo);


+ 1
- 1
distrho/src/DistrhoPluginInternal.hpp View File

@@ -89,7 +89,7 @@ void fillInPredefinedPortGroupData(const uint32_t groupId, PortGroup& portGroup)
}

static inline
void strncpy(char* const dst, const char* const src, const size_t length)
void d_strncpy(char* const dst, const char* const src, const size_t length)
{
DISTRHO_SAFE_ASSERT_RETURN(length > 0,);



+ 18
- 18
distrho/src/DistrhoPluginVST2.cpp View File

@@ -484,7 +484,7 @@ public:
case VST_EFFECT_OPCODE_04: // set program name
if (char* const programName = (char*)ptr)
{
strncpy(fProgramName, programName, 32);
d_strncpy(fProgramName, programName, 32);
return 1;
}
break;
@@ -492,7 +492,7 @@ public:
case VST_EFFECT_OPCODE_05: // get program name
if (char* const programName = (char*)ptr)
{
strncpy(programName, fProgramName, 24);
d_strncpy(programName, fProgramName, 24);
return 1;
}
break;
@@ -500,7 +500,7 @@ public:
case VST_EFFECT_OPCODE_1D: // get program name indexed
if (char* const programName = (char*)ptr)
{
strncpy(programName, fProgramName, 24);
d_strncpy(programName, fProgramName, 24);
return 1;
}
break;
@@ -1421,7 +1421,7 @@ static intptr_t VST_FUNCTION_INTERFACE vst_dispatcherCallback(vst_effect* const
case VST_EFFECT_OPCODE_PARAM_GETLABEL:
if (ptr != nullptr && index < static_cast<int32_t>(sPlugin->getParameterCount()))
{
strncpy((char*)ptr, sPlugin->getParameterUnit(index), 8);
d_strncpy((char*)ptr, sPlugin->getParameterUnit(index), 8);
return 1;
}
return 0;
@@ -1431,9 +1431,9 @@ static intptr_t VST_FUNCTION_INTERFACE vst_dispatcherCallback(vst_effect* const
{
const String& shortName(sPlugin->getParameterShortName(index));
if (shortName.isNotEmpty())
strncpy((char*)ptr, shortName, 16);
d_strncpy((char*)ptr, shortName, 16);
else
strncpy((char*)ptr, sPlugin->getParameterName(index), 16);
d_strncpy((char*)ptr, sPlugin->getParameterName(index), 16);
return 1;
}
return 0;
@@ -1446,17 +1446,17 @@ static intptr_t VST_FUNCTION_INTERFACE vst_dispatcherCallback(vst_effect* const
memset(properties, 0, sizeof(vst_parameter_properties));

// full name
strncpy(properties->name,
sPlugin->getParameterName(index),
sizeof(properties->name));
d_strncpy(properties->name,
sPlugin->getParameterName(index),
sizeof(properties->name));

// short name
const String& shortName(sPlugin->getParameterShortName(index));

if (shortName.isNotEmpty())
strncpy(properties->label,
sPlugin->getParameterShortName(index),
sizeof(properties->label));
d_strncpy(properties->label,
sPlugin->getParameterShortName(index),
sizeof(properties->label));

// parameter hints
const uint32_t hints = sPlugin->getParameterHints(index);
@@ -1496,9 +1496,9 @@ static intptr_t VST_FUNCTION_INTERFACE vst_dispatcherCallback(vst_effect* const
{
properties->flags |= VST_PARAMETER_FLAGS_CATEGORY;
properties->category = i + 1;
strncpy(properties->category_label,
portGroup.name.buffer(),
sizeof(properties->category_label));
d_strncpy(properties->category_label,
portGroup.name.buffer(),
sizeof(properties->category_label));
break;
}
}
@@ -1526,7 +1526,7 @@ static intptr_t VST_FUNCTION_INTERFACE vst_dispatcherCallback(vst_effect* const
case VST_EFFECT_OPCODE_EFFECT_NAME:
if (char* const cptr = (char*)ptr)
{
strncpy(cptr, sPlugin->getName(), 32);
d_strncpy(cptr, sPlugin->getName(), 32);
return 1;
}
return 0;
@@ -1534,7 +1534,7 @@ static intptr_t VST_FUNCTION_INTERFACE vst_dispatcherCallback(vst_effect* const
case VST_EFFECT_OPCODE_VENDOR_NAME:
if (char* const cptr = (char*)ptr)
{
strncpy(cptr, sPlugin->getMaker(), 32);
d_strncpy(cptr, sPlugin->getMaker(), 32);
return 1;
}
return 0;
@@ -1542,7 +1542,7 @@ static intptr_t VST_FUNCTION_INTERFACE vst_dispatcherCallback(vst_effect* const
case VST_EFFECT_OPCODE_PRODUCT_NAME:
if (char* const cptr = (char*)ptr)
{
strncpy(cptr, sPlugin->getLabel(), 32);
d_strncpy(cptr, sPlugin->getLabel(), 32);
return 1;
}
return 0;


+ 16
- 16
distrho/src/DistrhoPluginVST3.cpp View File

@@ -4715,9 +4715,9 @@ struct dpf_factory : v3_plugin_factory_cpp {
std::memset(info, 0, sizeof(*info));

info->flags = 0x10; // unicode
DISTRHO_NAMESPACE::strncpy(info->vendor, sPlugin->getMaker(), ARRAY_SIZE(info->vendor));
DISTRHO_NAMESPACE::strncpy(info->url, sPlugin->getHomePage(), ARRAY_SIZE(info->url));
// DISTRHO_NAMESPACE::strncpy(info->email, "", ARRAY_SIZE(info->email)); // TODO
d_strncpy(info->vendor, sPlugin->getMaker(), ARRAY_SIZE(info->vendor));
d_strncpy(info->url, sPlugin->getHomePage(), ARRAY_SIZE(info->url));
// d_strncpy(info->email, "", ARRAY_SIZE(info->email)); // TODO
return V3_OK;
}

@@ -4738,17 +4738,17 @@ struct dpf_factory : v3_plugin_factory_cpp {
DISTRHO_SAFE_ASSERT_RETURN(idx <= 2, V3_INVALID_ARG);

info->cardinality = 0x7FFFFFFF;
DISTRHO_NAMESPACE::strncpy(info->name, sPlugin->getName(), ARRAY_SIZE(info->name));
d_strncpy(info->name, sPlugin->getName(), ARRAY_SIZE(info->name));

if (idx == 0)
{
std::memcpy(info->class_id, dpf_tuid_class, sizeof(v3_tuid));
DISTRHO_NAMESPACE::strncpy(info->category, "Audio Module Class", ARRAY_SIZE(info->category));
d_strncpy(info->category, "Audio Module Class", ARRAY_SIZE(info->category));
}
else
{
std::memcpy(info->class_id, dpf_tuid_controller, sizeof(v3_tuid));
DISTRHO_NAMESPACE::strncpy(info->category, "Component Controller Class", ARRAY_SIZE(info->category));
d_strncpy(info->category, "Component Controller Class", ARRAY_SIZE(info->category));
}

return V3_OK;
@@ -4806,21 +4806,21 @@ struct dpf_factory : v3_plugin_factory_cpp {
#if DPF_VST3_USES_SEPARATE_CONTROLLER || !DISTRHO_PLUGIN_HAS_UI
info->class_flags = V3_DISTRIBUTABLE;
#endif
DISTRHO_NAMESPACE::strncpy(info->sub_categories, getPluginCategories(), ARRAY_SIZE(info->sub_categories));
DISTRHO_NAMESPACE::strncpy(info->name, sPlugin->getName(), ARRAY_SIZE(info->name));
DISTRHO_NAMESPACE::strncpy(info->vendor, sPlugin->getMaker(), ARRAY_SIZE(info->vendor));
DISTRHO_NAMESPACE::strncpy(info->version, getPluginVersion(), ARRAY_SIZE(info->version));
DISTRHO_NAMESPACE::strncpy(info->sdk_version, "Travesty 3.7.4", ARRAY_SIZE(info->sdk_version));
d_strncpy(info->sub_categories, getPluginCategories(), ARRAY_SIZE(info->sub_categories));
d_strncpy(info->name, sPlugin->getName(), ARRAY_SIZE(info->name));
d_strncpy(info->vendor, sPlugin->getMaker(), ARRAY_SIZE(info->vendor));
d_strncpy(info->version, getPluginVersion(), ARRAY_SIZE(info->version));
d_strncpy(info->sdk_version, "Travesty 3.7.4", ARRAY_SIZE(info->sdk_version));

if (idx == 0)
{
std::memcpy(info->class_id, dpf_tuid_class, sizeof(v3_tuid));
DISTRHO_NAMESPACE::strncpy(info->category, "Audio Module Class", ARRAY_SIZE(info->category));
d_strncpy(info->category, "Audio Module Class", ARRAY_SIZE(info->category));
}
else
{
std::memcpy(info->class_id, dpf_tuid_controller, sizeof(v3_tuid));
DISTRHO_NAMESPACE::strncpy(info->category, "Component Controller Class", ARRAY_SIZE(info->category));
d_strncpy(info->category, "Component Controller Class", ARRAY_SIZE(info->category));
}

return V3_OK;
@@ -4839,7 +4839,7 @@ struct dpf_factory : v3_plugin_factory_cpp {
#if DPF_VST3_USES_SEPARATE_CONTROLLER || !DISTRHO_PLUGIN_HAS_UI
info->class_flags = V3_DISTRIBUTABLE;
#endif
DISTRHO_NAMESPACE::strncpy(info->sub_categories, getPluginCategories(), ARRAY_SIZE(info->sub_categories));
d_strncpy(info->sub_categories, getPluginCategories(), ARRAY_SIZE(info->sub_categories));
DISTRHO_NAMESPACE::strncpy_utf16(info->name, sPlugin->getName(), ARRAY_SIZE(info->name));
DISTRHO_NAMESPACE::strncpy_utf16(info->vendor, sPlugin->getMaker(), ARRAY_SIZE(info->vendor));
DISTRHO_NAMESPACE::strncpy_utf16(info->version, getPluginVersion(), ARRAY_SIZE(info->version));
@@ -4848,12 +4848,12 @@ struct dpf_factory : v3_plugin_factory_cpp {
if (idx == 0)
{
std::memcpy(info->class_id, dpf_tuid_class, sizeof(v3_tuid));
DISTRHO_NAMESPACE::strncpy(info->category, "Audio Module Class", ARRAY_SIZE(info->category));
d_strncpy(info->category, "Audio Module Class", ARRAY_SIZE(info->category));
}
else
{
std::memcpy(info->class_id, dpf_tuid_controller, sizeof(v3_tuid));
DISTRHO_NAMESPACE::strncpy(info->category, "Component Controller Class", ARRAY_SIZE(info->category));
d_strncpy(info->category, "Component Controller Class", ARRAY_SIZE(info->category));
}

return V3_OK;


Loading…
Cancel
Save