pts: Use memchr(3) instead of strchr(3) to extract hash algorithm name
authorTobias Brunner <tobias@strongswan.org>
Tue, 1 Jul 2014 10:26:15 +0000 (12:26 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 1 Jul 2014 15:58:36 +0000 (17:58 +0200)
The string read with read(2) might not be null terminated.

src/libpts/pts/pts_ima_event_list.c

index a237451..9959fb3 100644 (file)
@@ -252,7 +252,7 @@ pts_ima_event_list_t* pts_ima_event_list_create(char *file)
                        }
 
                        /* extract the hash algorithm name */
-                       pos = strchr(algo_digest, '\0');
+                       pos = memchr(algo_digest, '\0', algo_digest_len);
                        if (!pos)
                        {
                                error = "no algo field";