Author: mpiulachs
Date: Wed Dec 19 00:20:59 2007
New Revision: 31310
URL:
http://svn.reactos.org/svn/reactos?rev=31310&view=rev
Log:
- Validate base address format
- Ensure base address value between 0x00400000 and 0x80000000
Modified:
branches/rbuild/reactos/tools/rbuild/module.cpp
branches/rbuild/reactos/tools/rbuild/project.cpp
branches/rbuild/reactos/tools/rbuild/rbuild.h
Modified: branches/rbuild/reactos/tools/rbuild/module.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/rbuild/reactos/tools/rbuild/mod…
==============================================================================
--- branches/rbuild/reactos/tools/rbuild/module.cpp (original)
+++ branches/rbuild/reactos/tools/rbuild/module.cpp Wed Dec 19 00:20:59 2007
@@ -2029,7 +2029,26 @@
const Module* module_ )
: Property( node_ , project_, module_)
{
- //TODO: Add code to validate baseaddress
+ if (Convert::IsValidHex(value))
+ {
+ if ((Convert::HexToInt(value) >= Convert::HexToInt("0x00400000"))
&&
+ (Convert::HexToInt(value) <= Convert::HexToInt("0x80000000")) )
+ {
+ //Is valid
+ }
+ else
+ throw XMLInvalidBuildFileException (
+ node->location,
+ "Out of range base address '%s' with value '%s'. Valid range
is from 0x00400000 to 0x80000000",
+ name.c_str(),
+ value.c_str());
+ }
+ else
+ throw XMLInvalidBuildFileException (
+ node->location,
+ "Base adress '%s' has an invalid hexadecimal value '%s'",
+ name.c_str(),
+ value.c_str() );
}
PchFile::PchFile (
Modified: branches/rbuild/reactos/tools/rbuild/project.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/rbuild/reactos/tools/rbuild/pro…
==============================================================================
--- branches/rbuild/reactos/tools/rbuild/project.cpp (original)
+++ branches/rbuild/reactos/tools/rbuild/project.cpp Wed Dec 19 00:20:59 2007
@@ -17,6 +17,7 @@
*/
#include "pch.h"
#include <assert.h>
+#include <sstream>
#include "rbuild.h"
#include "backend/backend.h"
@@ -33,6 +34,41 @@
value );
else
return "";
+}
+
+bool
+Convert::IsValidHex ( const std::string& value )
+{
+ return (HexToInt (value) != 0);
+}
+
+unsigned long
+Convert::HexToInt( const std::string& value )
+{
+ unsigned long num = 0;
+ std::istringstream ss(value);
+ ss >> std::hex;
+ if (!(ss >> num))
+ {
+ return 0;
+ }
+ return num;
+}
+
+std::string
+Convert::StringToHex (unsigned long num)
+{
+ std::string s1;
+ char sign[] =
{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
+ int div, base = 16;
+
+ while (num >= 1)
+ {
+ div = num % base;
+ num = num / base;
+ s1 = sign[div] + s1;
+ }
+ return s1;
}
string
Modified: branches/rbuild/reactos/tools/rbuild/rbuild.h
URL:
http://svn.reactos.org/svn/reactos/branches/rbuild/reactos/tools/rbuild/rbu…
==============================================================================
--- branches/rbuild/reactos/tools/rbuild/rbuild.h (original)
+++ branches/rbuild/reactos/tools/rbuild/rbuild.h Wed Dec 19 00:20:59 2007
@@ -197,6 +197,14 @@
bool InstallFiles;
};
+class Convert
+{
+public:
+ static unsigned long HexToInt ( const std::string& value );
+ static bool IsValidHex ( const std::string& value );
+ static std::string StringToHex ( unsigned long num);
+};
+
class Environment
{
public: