1570af302Sopenharmony_ci// commit cef0f289f666b6c963bfd11537a6d80916ff889e 2014-06-19 2570af302Sopenharmony_ci// memmem should not access oob data 3570af302Sopenharmony_ci#ifndef _GNU_SOURCE 4570af302Sopenharmony_ci#define _GNU_SOURCE 5570af302Sopenharmony_ci#endif 6570af302Sopenharmony_ci#include <string.h> 7570af302Sopenharmony_ci#include "test.h" 8570af302Sopenharmony_ci 9570af302Sopenharmony_ciint main(void) 10570af302Sopenharmony_ci{ 11570af302Sopenharmony_ci const unsigned char haystack[] = { 0,0,0,0,0,0,0,1,2 }; 12570af302Sopenharmony_ci const unsigned char needle[] = { 0,0,0,0,0,0,0,1,3 }; 13570af302Sopenharmony_ci unsigned char *p = memmem(haystack, 8, needle, 8); 14570af302Sopenharmony_ci if (!p) 15570af302Sopenharmony_ci t_error("memmem(A,8,A,8) returned 0, want A\n"); 16570af302Sopenharmony_ci return t_status; 17570af302Sopenharmony_ci} 18