25 lines
687 B
C
25 lines
687 B
C
#include <stddef.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
__attribute__((noinline)) int read_only_scanners(const char* haystack) {
|
|
const void* m = memchr(haystack, 'x', strlen(haystack));
|
|
const char* s = strstr(haystack, "needle");
|
|
const char* c = strchr(haystack, '=');
|
|
return (m != NULL) + (s != NULL) + (c != NULL);
|
|
}
|
|
|
|
__attribute__((noinline)) void safe_writer(char* dst, const char* src) {
|
|
char local[32];
|
|
memset(local, 0, sizeof(local));
|
|
memcpy(local, src, 8);
|
|
strncpy(dst, local, 31);
|
|
dst[31] = '\0';
|
|
}
|
|
|
|
int main(void) {
|
|
char dst[32];
|
|
safe_writer(dst, "needle=x");
|
|
printf("%d %s\n", read_only_scanners(dst), dst);
|
|
return 0;
|
|
}
|