mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 14:25:15 +00:00
Make hexchar() return -1 on invalid input instead of calling fatalx().
Callers used to check that the string was hex before calling hexchar(). Now callers must check for a -1 return value instead.
This commit is contained in:
@@ -46,7 +46,6 @@
|
||||
#if defined(HAVE_MALLOC_H) && !defined(STDC_HEADERS)
|
||||
# include <malloc.h>
|
||||
#endif /* HAVE_MALLOC_H && !STDC_HEADERS */
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "sudoers.h"
|
||||
@@ -61,6 +60,7 @@ bool
|
||||
fill_txt(const char *src, int len, int olen)
|
||||
{
|
||||
char *dst;
|
||||
int h;
|
||||
debug_decl(fill_txt, SUDO_DEBUG_PARSER)
|
||||
|
||||
dst = olen ? realloc(sudoerslval.string, olen + len + 1) : malloc(len + 1);
|
||||
@@ -75,10 +75,8 @@ fill_txt(const char *src, int len, int olen)
|
||||
dst += olen;
|
||||
while (len--) {
|
||||
if (*src == '\\' && len) {
|
||||
if (src[1] == 'x' && len >= 3 &&
|
||||
isxdigit((unsigned char) src[2]) &&
|
||||
isxdigit((unsigned char) src[3])) {
|
||||
*dst++ = hexchar(src + 2);
|
||||
if (src[1] == 'x' && len >= 3 && (h = hexchar(src + 2)) != -1) {
|
||||
*dst++ = h;
|
||||
src += 4;
|
||||
len -= 3;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user