* commit 'bb4961cd4f0348b5e88bdf81dded7b63d1aadb0b': add a fortified implementation of realpath
This commit is contained in:
		@@ -176,6 +176,27 @@ extern size_t __ctype_get_mb_cur_max(void);
 | 
				
			|||||||
#include <android/legacy_stdlib_inlines.h>
 | 
					#include <android/legacy_stdlib_inlines.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__BIONIC_FORTIFY)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern char* __realpath_real(const char*, char*) __RENAME(realpath);
 | 
				
			||||||
 | 
					__errordecl(__realpath_size_error, "realpath output parameter must be NULL or a >= PATH_MAX bytes buffer");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if !defined(__clang__)
 | 
				
			||||||
 | 
					__BIONIC_FORTIFY_INLINE
 | 
				
			||||||
 | 
					char* realpath(const char* path, char* resolved) {
 | 
				
			||||||
 | 
					    size_t bos = __bos(resolved);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* PATH_MAX is unavailable without polluting the namespace, but it's always 4096 on Linux */
 | 
				
			||||||
 | 
					    if (bos != __BIONIC_FORTIFY_UNKNOWN_SIZE && bos < 4096) {
 | 
				
			||||||
 | 
					        __realpath_size_error();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return __realpath_real(path, resolved);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* defined(__BIONIC_FORTIFY) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__END_DECLS
 | 
					__END_DECLS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* _STDLIB_H */
 | 
					#endif /* _STDLIB_H */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user