mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: add CString helper
This checks, up to the end of the frame, that we have a valid \0 for the CString before passing it back to the caller. Otherwise, NULL is returned for a corrupt/invalid CString within the frame.
This commit is contained in:
@ -80,4 +80,19 @@ SysprofDocumentFrame *_sysprof_document_frame_new (GMappedFile *ma
|
||||
(SYSPROF_DOCUMENT_FRAME_NEEDS_SWAP(obj) ? GINT64_TO_BE(val) : (val))
|
||||
#endif
|
||||
|
||||
static inline const char *
|
||||
SYSPROF_DOCUMENT_FRAME_CSTRING (SysprofDocumentFrame *self,
|
||||
const char *str)
|
||||
{
|
||||
const char *endptr = (const char *)self->frame + self->frame_len;
|
||||
|
||||
for (const char *c = str; c < endptr; c++)
|
||||
{
|
||||
if (*c == 0)
|
||||
return str;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
Reference in New Issue
Block a user