mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									d338b1379f
								
							
						
					
					
						commit
						8d82e180b5
					
				
					 1 changed files with 4 additions and 20 deletions
				
			
		| 
						 | 
					@ -23,6 +23,7 @@
 | 
				
			||||||
#include <linux/binfmts.h>
 | 
					#include <linux/binfmts.h>
 | 
				
			||||||
#include <linux/slab.h>
 | 
					#include <linux/slab.h>
 | 
				
			||||||
#include <linux/ctype.h>
 | 
					#include <linux/ctype.h>
 | 
				
			||||||
 | 
					#include <linux/string_helpers.h>
 | 
				
			||||||
#include <linux/file.h>
 | 
					#include <linux/file.h>
 | 
				
			||||||
#include <linux/pagemap.h>
 | 
					#include <linux/pagemap.h>
 | 
				
			||||||
#include <linux/namei.h>
 | 
					#include <linux/namei.h>
 | 
				
			||||||
| 
						 | 
					@ -234,24 +235,6 @@ static char *scanarg(char *s, char del)
 | 
				
			||||||
	return s;
 | 
						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)
 | 
					static char * check_special_flags (char * sfs, Node * e)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char * p = sfs;
 | 
						char * p = sfs;
 | 
				
			||||||
| 
						 | 
					@ -354,8 +337,9 @@ static Node *create_entry(const char __user *buffer, size_t count)
 | 
				
			||||||
		p[-1] = '\0';
 | 
							p[-1] = '\0';
 | 
				
			||||||
		if (!e->mask[0])
 | 
							if (!e->mask[0])
 | 
				
			||||||
			e->mask = NULL;
 | 
								e->mask = NULL;
 | 
				
			||||||
		e->size = unquote(e->magic);
 | 
							e->size = string_unescape_inplace(e->magic, UNESCAPE_HEX);
 | 
				
			||||||
		if (e->mask && unquote(e->mask) != e->size)
 | 
							if (e->mask &&
 | 
				
			||||||
 | 
							    string_unescape_inplace(e->mask, UNESCAPE_HEX) != e->size)
 | 
				
			||||||
			goto Einval;
 | 
								goto Einval;
 | 
				
			||||||
		if (e->size + e->offset > BINPRM_BUF_SIZE)
 | 
							if (e->size + e->offset > BINPRM_BUF_SIZE)
 | 
				
			||||||
			goto Einval;
 | 
								goto Einval;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue