@@ -1631,12 +1631,20 @@ struct commit_list **commit_list_append(struct commit *commit,
16311631 return & new_commit -> next ;
16321632}
16331633
1634- const char * find_commit_header (const char * msg , const char * key , size_t * out_len )
1634+ const char * find_header_mem (const char * msg , size_t len ,
1635+ const char * key , size_t * out_len )
16351636{
16361637 int key_len = strlen (key );
16371638 const char * line = msg ;
16381639
1639- while (line ) {
1640+ /*
1641+ * NEEDSWORK: It's possible for strchrnul() to scan beyond the range
1642+ * given by len. However, current callers are safe because they compute
1643+ * len by scanning a NUL-terminated block of memory starting at msg.
1644+ * Nonetheless, it would be better to ensure the function does not look
1645+ * at msg beyond the len provided by the caller.
1646+ */
1647+ while (line && line < msg + len ) {
16401648 const char * eol = strchrnul (line , '\n' );
16411649
16421650 if (line == eol )
@@ -1653,6 +1661,10 @@ const char *find_commit_header(const char *msg, const char *key, size_t *out_len
16531661 return NULL ;
16541662}
16551663
1664+ const char * find_commit_header (const char * msg , const char * key , size_t * out_len )
1665+ {
1666+ return find_header_mem (msg , strlen (msg ), key , out_len );
1667+ }
16561668/*
16571669 * Inspect the given string and determine the true "end" of the log message, in
16581670 * order to find where to put a new Signed-off-by trailer. Ignored are
0 commit comments