mirror of
https://github.com/serge1/ELFIO.git
synced 2024-11-02 11:27:03 +00:00
Address warnings reported by MS VS analyzer
This commit is contained in:
parent
3c434f7587
commit
a8831c5d74
@ -70,7 +70,7 @@ template <class S> class note_section_accessor_template
|
|||||||
int align = sizeof( Elf_Word );
|
int align = sizeof( Elf_Word );
|
||||||
|
|
||||||
const endianess_convertor& convertor = elf_file.get_convertor();
|
const endianess_convertor& convertor = elf_file.get_convertor();
|
||||||
type = convertor( *(const Elf_Word*)( pData + 2 * align ) );
|
type = convertor( *(const Elf_Word*)( pData + 2 * (size_t)align ) );
|
||||||
Elf_Word namesz = convertor( *(const Elf_Word*)( pData ) );
|
Elf_Word namesz = convertor( *(const Elf_Word*)( pData ) );
|
||||||
descSize = convertor( *(const Elf_Word*)( pData + sizeof( namesz ) ) );
|
descSize = convertor( *(const Elf_Word*)( pData + sizeof( namesz ) ) );
|
||||||
|
|
||||||
@ -80,14 +80,14 @@ template <class S> class note_section_accessor_template
|
|||||||
(Elf_Xword)namesz + descSize > max_name_size ) {
|
(Elf_Xword)namesz + descSize > max_name_size ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
name.assign( pData + 3 * align, namesz - 1 );
|
name.assign( pData + 3 * (size_t)align, namesz - 1 );
|
||||||
if ( 0 == descSize ) {
|
if ( 0 == descSize ) {
|
||||||
desc = 0;
|
desc = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
desc =
|
desc = const_cast<char*>( pData + 3 * (size_t)align +
|
||||||
const_cast<char*>( pData + 3 * align +
|
( ( namesz + align - 1 ) / align ) *
|
||||||
( ( namesz + align - 1 ) / align ) * align );
|
(size_t)align );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -114,12 +114,12 @@ template <class S> class note_section_accessor_template
|
|||||||
buffer.append( 1, '\x00' );
|
buffer.append( 1, '\x00' );
|
||||||
const char pad[] = { '\0', '\0', '\0', '\0' };
|
const char pad[] = { '\0', '\0', '\0', '\0' };
|
||||||
if ( nameLen % align != 0 ) {
|
if ( nameLen % align != 0 ) {
|
||||||
buffer.append( pad, align - nameLen % align );
|
buffer.append( pad, (size_t)align - nameLen % align );
|
||||||
}
|
}
|
||||||
if ( desc != 0 && descSize != 0 ) {
|
if ( desc != 0 && descSize != 0 ) {
|
||||||
buffer.append( reinterpret_cast<const char*>( desc ), descSize );
|
buffer.append( reinterpret_cast<const char*>( desc ), descSize );
|
||||||
if ( descSize % align != 0 ) {
|
if ( descSize % align != 0 ) {
|
||||||
buffer.append( pad, (size_t)( align - descSize % align ) );
|
buffer.append( pad, (size_t)align - descSize % align );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ ELFIO_C_GET_ACCESS_IMPL( section, Elf64_Off, offset );
|
|||||||
|
|
||||||
void elfio_section_get_name( psection_t psection, char* buffer, int len )
|
void elfio_section_get_name( psection_t psection, char* buffer, int len )
|
||||||
{
|
{
|
||||||
strncpy( buffer, psection->get_name().c_str(), len - 1 );
|
strncpy( buffer, psection->get_name().c_str(), (size_t)len - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void elfio_section_set_name( psection_t psection, char* buffer )
|
void elfio_section_set_name( psection_t psection, char* buffer )
|
||||||
@ -225,7 +225,7 @@ bool elfio_symbol_get_symbol( psymbol_t psymbol,
|
|||||||
std::string name_param;
|
std::string name_param;
|
||||||
bool ret = psymbol->get_symbol( index, name_param, *value, *size, *bind,
|
bool ret = psymbol->get_symbol( index, name_param, *value, *size, *bind,
|
||||||
*type, *section_index, *other );
|
*type, *section_index, *other );
|
||||||
strncpy( name, name_param.c_str(), name_len - 1 );
|
strncpy( name, name_param.c_str(), (size_t)name_len - 1 );
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -350,7 +350,7 @@ bool elfio_note_get_note( pnote_t pnote,
|
|||||||
{
|
{
|
||||||
std::string name_str;
|
std::string name_str;
|
||||||
bool ret = pnote->get_note( index, *type, name_str, *desc, *descSize );
|
bool ret = pnote->get_note( index, *type, name_str, *desc, *descSize );
|
||||||
strncpy( name, name_str.c_str(), name_len - 1 );
|
strncpy( name, name_str.c_str(), (size_t)name_len - 1 );
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -392,8 +392,8 @@ bool elfio_modinfo_get_attribute( pmodinfo_t pmodinfo,
|
|||||||
std::string field_str;
|
std::string field_str;
|
||||||
std::string value_str;
|
std::string value_str;
|
||||||
bool ret = pmodinfo->get_attribute( no, field_str, value_str );
|
bool ret = pmodinfo->get_attribute( no, field_str, value_str );
|
||||||
strncpy( field, field_str.c_str(), field_len - 1 );
|
strncpy( field, field_str.c_str(), (size_t)field_len - 1 );
|
||||||
strncpy( value, value_str.c_str(), value_len - 1 );
|
strncpy( value, value_str.c_str(), (size_t)value_len - 1 );
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -405,7 +405,7 @@ bool elfio_modinfo_get_attribute_by_name( pmodinfo_t pmodinfo,
|
|||||||
{
|
{
|
||||||
std::string value_str;
|
std::string value_str;
|
||||||
bool ret = pmodinfo->get_attribute( value_str, value_str );
|
bool ret = pmodinfo->get_attribute( value_str, value_str );
|
||||||
strncpy( value, value_str.c_str(), value_len - 1 );
|
strncpy( value, value_str.c_str(), (size_t)value_len - 1 );
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -444,7 +444,7 @@ bool elfio_dynamic_get_entry( pdynamic_t pdynamic,
|
|||||||
{
|
{
|
||||||
std::string str_str;
|
std::string str_str;
|
||||||
bool ret = pdynamic->get_entry( index, *tag, *value, str_str );
|
bool ret = pdynamic->get_entry( index, *tag, *value, str_str );
|
||||||
strncpy( str, str_str.c_str(), str_len - 1 );
|
strncpy( str, str_str.c_str(), (size_t)str_len - 1 );
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user