diff options
| author | sin | 2015-04-08 15:25:47 +0100 |
|---|---|---|
| committer | sin | 2015-04-08 15:25:47 +0100 |
| commit | c7e82d4863992c2f3bbb6f5a31fa8e5fd0e1643f (patch) | |
| tree | 06ef04aeb700a4c434da240332b906a91db49427 /include/strings.h | |
| parent | 2bd3091b3636a18360e4c8bc2393daaf475f43cb (diff) | |
Add read checks for bcopy()
Diffstat (limited to 'include/strings.h')
| -rw-r--r-- | include/strings.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/include/strings.h b/include/strings.h index 2a16c60..4e0c194 100644 --- a/include/strings.h +++ b/include/strings.h | |||
| @@ -16,13 +16,14 @@ extern "C" { | |||
| 16 | #undef bzero | 16 | #undef bzero |
| 17 | __typeof__(bcopy) __bcopy_orig __asm__(__USER_LABEL_PREFIX__ "bcopy"); | 17 | __typeof__(bcopy) __bcopy_orig __asm__(__USER_LABEL_PREFIX__ "bcopy"); |
| 18 | extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__)) | 18 | extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__)) |
| 19 | void bcopy(const void *src, void *dest, size_t n) | 19 | void bcopy(const void *src, void *dst, size_t n) |
| 20 | { | 20 | { |
| 21 | size_t bos = __builtin_object_size(dest, 0); | 21 | size_t bos_dst = __builtin_object_size(dst, 0); |
| 22 | size_t bos_src = __builtin_object_size(src, 0); | ||
| 22 | 23 | ||
| 23 | if (n > bos) | 24 | if (n > bos_dst || n > bos_src) |
| 24 | __builtin_trap(); | 25 | __builtin_trap(); |
| 25 | return __bcopy_orig(src, dest, n); | 26 | return __bcopy_orig(src, dst, n); |
| 26 | } | 27 | } |
| 27 | 28 | ||
| 28 | __typeof__(bzero) __bzero_orig __asm__(__USER_LABEL_PREFIX__ "bzero"); | 29 | __typeof__(bzero) __bzero_orig __asm__(__USER_LABEL_PREFIX__ "bzero"); |
