aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rpmoffset.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/rpmoffset.c b/rpmoffset.c
index 0a3c488..628af93 100644
--- a/rpmoffset.c
+++ b/rpmoffset.c
@@ -19,6 +19,26 @@
# define BUFSIZ 8192
#endif
+#if !defined(__GLIBC__)
+static void *rp_memmem(const void *buf, size_t buflen, const void *pattern, size_t len)
+{
+ char *bf = (char *)buf, *pt = (char *)pattern, *p = bf;
+
+ while (len <= (buflen - (p - bf))) {
+ if (NULL != (p = memchr(p, (int)(*pt), buflen - (p - bf)))) {
+ if (0 == memcmp(p, pattern, len))
+ return p;
+ else
+ ++p;
+ }
+ else
+ break;
+ }
+ return NULL;
+}
+#define memmem(a,b,c,d) rp_memmem(a,b,c,d)
+#endif
+
typedef struct {
const char *type;
const unsigned char *magic;