Skip to content

Commit 6ab1332

Browse files
committed
Fix out-of-bounds string manipulation causing segfault.
If registerForEvents() is called with "libredfish" for the postbackUri parameter, the function accepts this string and passes a pointer to 'postbackUri+11' to getDestinationAddress. In this case, the pointer actually points past the end of the string's null byte. On CHERI architectures, such as ARM Morello, pointer bounds are enforced in hardware and attempting to dereference the pointer passed to getDestinationAddress() causes a segfault. Valid values for postbackUri should include a colon after "libredfish", checking for this as part of the strncmp call rejects the invalid string "libredfish" and this also means that getDestinationAddress() is not passed an invalid pointer. This prevents a segfault on CHERI and prevents undefined behavior on other architectures. Signed-off-by: Michael Cobb <[email protected]>
1 parent 1795647 commit 6ab1332

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/service.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ bool registerForEvents(redfishService* service, const char* postbackUri, unsigne
932932
}
933933

934934
//User wants libredfish to listen for events directly...
935-
if(strncmp(postbackUri, "libredfish", 10) == 0)
935+
if(strncmp(postbackUri, "libredfish:", 11) == 0)
936936
{
937937
destination = getDestinationAddress(postbackUri+11, &socket);
938938
if(destination == NULL)

0 commit comments

Comments
 (0)