Skip to content

Commit

Permalink
Fix #966, update padding in CDS registry record
Browse files Browse the repository at this point in the history
As the name field is a multiple of 4 bytes, there needs to be 3 bytes
of padding, not 1, to avoid implicit padding.

This doesn't change anything, it just makes the padding explicit instead
of implicit.
  • Loading branch information
jphickey committed Oct 27, 2020
1 parent e6296e6 commit d21d94a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions fsw/cfe-core/src/es/cfe_es_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -1827,14 +1827,11 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistry_t *data)
if ( CFE_ES_CDSBlockRecordIsUsed(RegRecPtr) )
{
/* Fill CDS Registry Dump Record with relevant information */
memset(&DumpRecord, 0, sizeof(DumpRecord));
DumpRecord.Size = CFE_ES_CDSBlockRecordGetUserSize(RegRecPtr);
DumpRecord.Handle = CFE_ES_CDSBlockRecordGetID(RegRecPtr);
DumpRecord.Table = RegRecPtr->Table;
DumpRecord.ByteAlignSpare1 = 0;

/* strncpy will zero out any unused buffer - memset not necessary */
strncpy(DumpRecord.Name, RegRecPtr->Name, sizeof(DumpRecord.Name)-1);
DumpRecord.Name[sizeof(DumpRecord.Name)-1] = 0;

/* Output Registry Dump Record to Registry Dump File */
Status = OS_write(FileDescriptor,
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/inc/cfe_es_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ typedef struct CFE_ES_CDSRegDumpRec
CFE_ES_CDS_Offset_t Size; /**< \brief Size, in bytes, of the CDS memory block */
bool Table; /**< \brief Flag that indicates whether CDS contains a Critical Table */
char Name[CFE_MISSION_ES_CDS_MAX_NAME_LEN]; /**< \brief Processor Unique Name of CDS */
uint8 ByteAlignSpare1; /**< \brief Spare byte to insure structure size is multiple of 4 bytes */
uint8 ByteAlignSpare[3]; /**< \brief Spare bytes to ensure structure size is multiple of 4 bytes */
} CFE_ES_CDSRegDumpRec_t;

/**
Expand Down

0 comments on commit d21d94a

Please sign in to comment.