| 1782 | |
| 1783 | |
| 1784 | static int mget(request_rec *r, union VALUETYPE *p, unsigned char *s, |
| 1785 | struct magic *m, apr_size_t nbytes) |
| 1786 | { |
| 1787 | long offset = m->offset; |
| 1788 | |
| 1789 | if (offset + sizeof(union VALUETYPE) > nbytes) |
| 1790 | return 0; |
| 1791 | |
| 1792 | memcpy(p, s + offset, sizeof(union VALUETYPE)); |
| 1793 | |
| 1794 | if (!mconvert(r, p, m)) |
| 1795 | return 0; |
| 1796 | |
| 1797 | if (m->flag & INDIR) { |
| 1798 | |
| 1799 | switch (m->in.type) { |
| 1800 | case BYTE: |
| 1801 | offset = p->b + m->in.offset; |
| 1802 | break; |
| 1803 | case SHORT: |
| 1804 | offset = p->h + m->in.offset; |
| 1805 | break; |
| 1806 | case LONG: |
| 1807 | offset = p->l + m->in.offset; |
| 1808 | break; |
| 1809 | } |
| 1810 | |
| 1811 | if (offset + sizeof(union VALUETYPE) > nbytes) |
| 1812 | return 0; |
| 1813 | |
| 1814 | memcpy(p, s + offset, sizeof(union VALUETYPE)); |
| 1815 | |
| 1816 | if (!mconvert(r, p, m)) |
| 1817 | return 0; |
| 1818 | } |
| 1819 | return 1; |
| 1820 | } |
| 1821 | |
| 1822 | static int mcheck(request_rec *r, union VALUETYPE *p, struct magic *m) |
| 1823 | { |