Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F105536822
D34368.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D34368.diff
View Options
diff --git a/usr.bin/dtc/fdt.cc b/usr.bin/dtc/fdt.cc
--- a/usr.bin/dtc/fdt.cc
+++ b/usr.bin/dtc/fdt.cc
@@ -335,10 +335,28 @@
unsigned long long val;
if (!input.consume_integer_expression(val))
{
+ // FIXME: Distinguish invalid syntax from a
+ // number that cannot be represented in an
+ // unsigned long long.
input.parse_error("Expected numbers in array of cells");
valid = false;
return;
}
+ // FIXME: No sign information available, so cannot
+ // distinguish small negative values from large
+ // positive ones, and thus we have to conservatively
+ // permit anything that looks like a sign-extended
+ // negative integer.
+ if (cell_size < 64 && val >= (1ull << cell_size) &&
+ (val | ((1ull << (cell_size - 1)) - 1)) !=
+ std::numeric_limits<unsigned long long>::max())
+ {
+ std::string msg = "Value does not fit in a " +
+ std::to_string(cell_size) + "-bit cell";
+ input.parse_error(msg.c_str());
+ valid = false;
+ return;
+ }
switch (cell_size)
{
case 8:
diff --git a/usr.bin/dtc/input_buffer.cc b/usr.bin/dtc/input_buffer.cc
--- a/usr.bin/dtc/input_buffer.cc
+++ b/usr.bin/dtc/input_buffer.cc
@@ -349,8 +349,11 @@
return false;
}
char *end= const_cast<char*>(&buffer[size]);
+ errno = 0;
outInt = strtoull(&buffer[cursor], &end, 0);
- if (end == &buffer[cursor])
+ if (end == &buffer[cursor] ||
+ (outInt == std::numeric_limits<unsigned long long>::max() &&
+ errno == ERANGE))
{
return false;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 18, 9:52 AM (11 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15484274
Default Alt Text
D34368.diff (1 KB)
Attached To
Mode
D34368: dtc: Sync with upstream version e9a77451cdd8
Attached
Detach File
Event Timeline
Log In to Comment