aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2013-04-30 18:27:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-30 20:04:03 -0400
commit8d82e180b51f8ecca9ae9d6a3e7f01d50ea34c20 (patch)
tree2aee6ab908aa656019327f277716dcd6f9995db5
parentd338b1379f96b20e63aa65082e19e9a18a93b608 (diff)
binfmt_misc: reuse string_unescape_inplace()
There is string_unescape_inplace() function which decodes strings in generic way. Let's use it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/binfmt_misc.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 751df5e4f61a..1c740e152f38 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -23,6 +23,7 @@
23#include <linux/binfmts.h> 23#include <linux/binfmts.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/ctype.h> 25#include <linux/ctype.h>
26#include <linux/string_helpers.h>
26#include <linux/file.h> 27#include <linux/file.h>
27#include <linux/pagemap.h> 28#include <linux/pagemap.h>
28#include <linux/namei.h> 29#include <linux/namei.h>
@@ -234,24 +235,6 @@ static char *scanarg(char *s, char del)
234 return s; 235 return s;
235} 236}
236 237
237static int unquote(char *from)
238{
239 char c = 0, *s = from, *p = from;
240
241 while ((c = *s++) != '\0') {
242 if (c == '\\' && *s == 'x') {
243 s++;
244 c = toupper(*s++);
245 *p = (c - (isdigit(c) ? '0' : 'A' - 10)) << 4;
246 c = toupper(*s++);
247 *p++ |= c - (isdigit(c) ? '0' : 'A' - 10);
248 continue;
249 }
250 *p++ = c;
251 }
252 return p - from;
253}
254
255static char * check_special_flags (char * sfs, Node * e) 238static char * check_special_flags (char * sfs, Node * e)
256{ 239{
257 char * p = sfs; 240 char * p = sfs;
@@ -354,8 +337,9 @@ static Node *create_entry(const char __user *buffer, size_t count)
354 p[-1] = '\0'; 337 p[-1] = '\0';
355 if (!e->mask[0]) 338 if (!e->mask[0])
356 e->mask = NULL; 339 e->mask = NULL;
357 e->size = unquote(e->magic); 340 e->size = string_unescape_inplace(e->magic, UNESCAPE_HEX);
358 if (e->mask && unquote(e->mask) != e->size) 341 if (e->mask &&
342 string_unescape_inplace(e->mask, UNESCAPE_HEX) != e->size)
359 goto Einval; 343 goto Einval;
360 if (e->size + e->offset > BINPRM_BUF_SIZE) 344 if (e->size + e->offset > BINPRM_BUF_SIZE)
361 goto Einval; 345 goto Einval;