* l_memmem() returns the location of the first occurrence of data * pattern b2 of size len2 in memory block b1 of size len1 or * NULL if none is found. Obtained from NetBSD. */
| 1558 | * NULL if none is found. Obtained from NetBSD. |
| 1559 | */ |
| 1560 | static inline void * l_memmem(const void *b1, const void *b2, |
| 1561 | size_t len1, size_t len2) |
| 1562 | { |
| 1563 | /* Initialize search pointer */ |
| 1564 | char *sp = (char *) b1; |
| 1565 | |
| 1566 | /* Initialize pattern pointer */ |
| 1567 | char *pp = (char *) b2; |
| 1568 | |
| 1569 | /* Initialize end of search address space pointer */ |
| 1570 | char *eos = sp + len1 - len2; |
| 1571 | |
| 1572 | /* Sanity check */ |
| 1573 | if(!(b1 && b2 && len1 && len2)) |
| 1574 | return NULL; |
| 1575 | |
| 1576 | while (sp <= eos) { |
| 1577 | if (*sp == *pp) |
| 1578 | if (memcmp(sp, pp, len2) == 0) |
| 1579 | return sp; |
| 1580 | |
| 1581 | sp++; |
| 1582 | } |
| 1583 | |
| 1584 | return NULL; |
| 1585 | } |
| 1586 | |
| 1587 | /** |
| 1588 | * Make any database URL log-friendly by masking its password, if any |
no outgoing calls
no test coverage detected