From 67d1814c77227a1a65df7a8393414cdd4434c3e3 Mon Sep 17 00:00:00 2001 From: Xi Wang Date: Fri, 20 Apr 2012 15:49:44 -0500 Subject: [PATCH] --- yaml --- r: 309446 b: refs/heads/master c: 76aa542fb90e3e91edb1146d10ca7cf2cae8e7e9 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/linux/ceph/decode.h | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index a56ef7db4daa..7f15d88cb0f4 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 065a68f9167e20f321a62d044cb2c3024393d455 +refs/heads/master: 76aa542fb90e3e91edb1146d10ca7cf2cae8e7e9 diff --git a/trunk/include/linux/ceph/decode.h b/trunk/include/linux/ceph/decode.h index c5b6939fb32a..ecf324eb2c9a 100644 --- a/trunk/include/linux/ceph/decode.h +++ b/trunk/include/linux/ceph/decode.h @@ -45,9 +45,14 @@ static inline void ceph_decode_copy(void **p, void *pv, size_t n) /* * bounds check input. */ +static inline int ceph_has_room(void **p, void *end, size_t n) +{ + return end >= *p && n <= end - *p; +} + #define ceph_decode_need(p, end, n, bad) \ do { \ - if (unlikely(*(p) + (n) > (end))) \ + if (!likely(ceph_has_room(p, end, n))) \ goto bad; \ } while (0) @@ -166,7 +171,7 @@ static inline void ceph_encode_string(void **p, void *end, #define ceph_encode_need(p, end, n, bad) \ do { \ - if (unlikely(*(p) + (n) > (end))) \ + if (!likely(ceph_has_room(p, end, n))) \ goto bad; \ } while (0)