From: Andy Shevchenko Date: Tue, 30 Apr 2013 22:27:33 +0000 (-0700) Subject: binfmt_misc: reuse string_unescape_inplace() X-Git-Tag: firefly_0821_release~3680^2~625^2~73 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8d82e180b51f8ecca9ae9d6a3e7f01d50ea34c20;p=firefly-linux-kernel-4.4.55.git 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 Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Linus Torvalds --- 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 @@ #include #include #include +#include #include #include #include @@ -234,24 +235,6 @@ static char *scanarg(char *s, char del) return s; } -static int unquote(char *from) -{ - char c = 0, *s = from, *p = from; - - while ((c = *s++) != '\0') { - if (c == '\\' && *s == 'x') { - s++; - c = toupper(*s++); - *p = (c - (isdigit(c) ? '0' : 'A' - 10)) << 4; - c = toupper(*s++); - *p++ |= c - (isdigit(c) ? '0' : 'A' - 10); - continue; - } - *p++ = c; - } - return p - from; -} - static char * check_special_flags (char * sfs, Node * e) { char * p = sfs; @@ -354,8 +337,9 @@ static Node *create_entry(const char __user *buffer, size_t count) p[-1] = '\0'; if (!e->mask[0]) e->mask = NULL; - e->size = unquote(e->magic); - if (e->mask && unquote(e->mask) != e->size) + e->size = string_unescape_inplace(e->magic, UNESCAPE_HEX); + if (e->mask && + string_unescape_inplace(e->mask, UNESCAPE_HEX) != e->size) goto Einval; if (e->size + e->offset > BINPRM_BUF_SIZE) goto Einval;