mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-29 18:49:22 +00:00
kern/misc: Add STRING type for internal printf() format handling
Set printf() argument type for "%s" to new type STRING. This is in preparation for a follow up patch to compare a printf() format string against an expected printf() format string. For "%s" the corresponding printf() argument is dereferenced as pointer while all other argument types are defined as integer value. However, when validating a printf() format it is necessary to differentiate "%s" from "%p" and other integers. So, let's do that. Signed-off-by: Thomas Frauendorfer | Miray Software <tf@miray.de> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
7f11bde314
commit
1a2a5aff71
1 file changed
+11
-2
+11
-2
@@ -33,7 +33,8 @@ union printf_arg
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
INT, LONG, LONGLONG,
|
INT, LONG, LONGLONG,
|
||||||
UNSIGNED_INT = 3, UNSIGNED_LONG, UNSIGNED_LONGLONG
|
UNSIGNED_INT = 3, UNSIGNED_LONG, UNSIGNED_LONGLONG,
|
||||||
|
STRING
|
||||||
} type;
|
} type;
|
||||||
long long ll;
|
long long ll;
|
||||||
};
|
};
|
||||||
@@ -791,12 +792,14 @@ parse_printf_arg_fmt (const char *fmt0, struct printf_args *args)
|
|||||||
args->ptr[curn].type = INT + longfmt;
|
args->ptr[curn].type = INT + longfmt;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
case 's':
|
|
||||||
if (sizeof (void *) == sizeof (long long))
|
if (sizeof (void *) == sizeof (long long))
|
||||||
args->ptr[curn].type = UNSIGNED_LONGLONG;
|
args->ptr[curn].type = UNSIGNED_LONGLONG;
|
||||||
else
|
else
|
||||||
args->ptr[curn].type = UNSIGNED_INT;
|
args->ptr[curn].type = UNSIGNED_INT;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
args->ptr[curn].type = STRING;
|
||||||
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
case 'c':
|
case 'c':
|
||||||
args->ptr[curn].type = INT;
|
args->ptr[curn].type = INT;
|
||||||
@@ -831,6 +834,12 @@ parse_printf_args (const char *fmt0, struct printf_args *args, va_list args_in)
|
|||||||
case UNSIGNED_LONGLONG:
|
case UNSIGNED_LONGLONG:
|
||||||
args->ptr[n].ll = va_arg (args_in, long long);
|
args->ptr[n].ll = va_arg (args_in, long long);
|
||||||
break;
|
break;
|
||||||
|
case STRING:
|
||||||
|
if (sizeof (void *) == sizeof (long long))
|
||||||
|
args->ptr[n].ll = va_arg (args_in, long long);
|
||||||
|
else
|
||||||
|
args->ptr[n].ll = va_arg (args_in, unsigned int);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user