[moserial] don't assign a negative integer to a char, bug 757733
- From: Michael J. Chudobiak <mjc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [moserial] don't assign a negative integer to a char, bug 757733
- Date: Mon, 9 Nov 2015 14:41:38 +0000 (UTC)
commit 84d65b4fbc5f4b06c80e492451465719471d3682
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Mon Nov 9 09:41:03 2015 -0500
don't assign a negative integer to a char, bug 757733
src/InputParser.vala | 26 ++++++++++++--------------
1 files changed, 12 insertions(+), 14 deletions(-)
---
diff --git a/src/InputParser.vala b/src/InputParser.vala
index d1bd7a6..6e5018e 100644
--- a/src/InputParser.vala
+++ b/src/InputParser.vala
@@ -39,24 +39,22 @@ public class InputParser : GLib.Object
c=s.get_char();
+ i=xtoi(c);
+ if(i>15)
+ throw new HexParseError.INVALID_INPUT(_("Invalid Input"));
+
if(len>1) {
- i=xtoi(c)*16;
- if(i<0)
- throw new HexParseError.INVALID_INPUT(_("Invalid Input"));
+ i*=16;
+
s=s.next_char();
-
c=s.get_char();
-
+
temp=xtoi(c);
- if(temp<0)
- throw new HexParseError.INVALID_INPUT(_("Invalid Input"));
- i=i+temp;
- }
- else {
- i=xtoi(c);
- if(i<0)
+ if(temp>15)
throw new HexParseError.INVALID_INPUT(_("Invalid Input"));
+ i+=temp;
}
+
s=s.next_char();
r[x]=(uchar)i;
}
@@ -65,8 +63,8 @@ public class InputParser : GLib.Object
}
// There should be bindings to something in vala that can do this but there dosen't seem to be yet
2009-01-31
- private static char xtoi(unichar c) {
- char i=-1;
+ private static uchar xtoi(unichar c) {
+ char i=16; // an invalid positive result
switch(c){
case '0':
i=0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]