mirror of
https://github.com/openwrt/openwrt.git
synced 2026-10-12 06:57:57 +04:00
tools/mkimage: reject empty custom magic
Reject custom magic values when strtoull() does not parse any digits, in addition to values outside the 32-bit uImage magic range. Signed-off-by: Massimo Mazzariol <mazzariol.massimo@gmail.com> Link: https://github.com/openwrt/openwrt/pull/25288 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
1 parent
36efe835fd
commit
6f684052de
1 file changed
+2
-2
@@ -42,7 +42,7 @@ This patch makes it possible to set a custom image magic.
|
||||
break;
|
||||
+ case 'M':
|
||||
+ magic = strtoull(optarg, &ptr, 16);
|
||||
+ if (*ptr || magic > UINT32_MAX) {
|
||||
+ if (ptr == optarg || *ptr || magic > UINT32_MAX) {
|
||||
+ fprintf(stderr, "%s: invalid magic %s\n",
|
||||
+ params.cmdname, optarg);
|
||||
+ exit(EXIT_FAILURE);
|
||||
@@ -126,7 +126,7 @@ This patch makes it possible to set a custom image magic.
|
||||
break;
|
||||
+ case 'M':
|
||||
+ magic = strtoull(optarg, &ptr, 16);
|
||||
+ if (*ptr || magic > UINT32_MAX) {
|
||||
+ if (ptr == optarg || *ptr || magic > UINT32_MAX) {
|
||||
+ fprintf(stderr, "%s: invalid magic %s\n",
|
||||
+ params.cmdname, optarg);
|
||||
+ exit(EXIT_FAILURE);
|
||||
|
||||
Reference in new issue
Block a user