Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1175068 > unrolled thread

[PATCH 2/3] lib/bitmap.c: fix a special string handling bug in __bitmap_parselist

Started byPan Xinhui <xinhuix.pan@intel.com>
First post2015-07-01 10:10 +0200
Last post2015-07-01 10:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/3] lib/bitmap.c: fix a special string handling bug in  __bitmap_parselist Pan Xinhui <xinhuix.pan@intel.com> - 2015-07-01 10:10 +0200

#1175068 — [PATCH 2/3] lib/bitmap.c: fix a special string handling bug in __bitmap_parselist

FromPan Xinhui <xinhuix.pan@intel.com>
Date2015-07-01 10:10 +0200
Subject[PATCH 2/3] lib/bitmap.c: fix a special string handling bug in __bitmap_parselist
Message-ID<pHlfI-2Ay-25@gated-at.bofh.it>
If string end with '-', for exapmle, bitmap_parselist("1,0-",&mask, nmaskbits),
It is not in a valid pattern, so add a check after loop.
Return -EINVAL on such condition.

Signed-off-by: Pan Xinhui <xinhuix.pan@intel.com>
---
  lib/bitmap.c | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/lib/bitmap.c b/lib/bitmap.c
index eb21456..f549176 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -546,6 +546,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
  					return -EINVAL;
  				b = 0;
  				in_range = 1;
+				at_start = 1;
  				continue;
  			}
  
@@ -558,6 +559,9 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
  			at_start = 0;
  			totaldigits++;
  		}
+		/* if no digit is after '-', it's wrong*/
+		if (at_start && in_range)
+			return -EINVAL;
  		if (!(a <= b))
  			return -EINVAL;
  		if (b >= nmaskbits)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web