aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2012-08-13 14:42:00 +0200
committerMicael Karlberg <[email protected]>2012-08-13 14:42:00 +0200
commit3cdb7781aca3cfff24485f7a9dbe704a4824d5e1 (patch)
tree33db08583bd59ee50895f9b895de13c6f846ca69 /lib/snmp/src
parentdb929c5aacb412eb94fbe0757a47a41564e6fb51 (diff)
downloadotp-3cdb7781aca3cfff24485f7a9dbe704a4824d5e1.tar.gz
otp-3cdb7781aca3cfff24485f7a9dbe704a4824d5e1.tar.bz2
otp-3cdb7781aca3cfff24485f7a9dbe704a4824d5e1.zip
[snmp] Add bug compatible fixes to TimeTicks decode
Add handling of incorrectly encoded TimeTicks and Unsigned32.
Diffstat (limited to 'lib/snmp/src')
-rw-r--r--lib/snmp/src/misc/snmp_pdus.erl28
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/snmp/src/misc/snmp_pdus.erl b/lib/snmp/src/misc/snmp_pdus.erl
index e15be4a298..5b8be90a71 100644
--- a/lib/snmp/src/misc/snmp_pdus.erl
+++ b/lib/snmp/src/misc/snmp_pdus.erl
@@ -298,22 +298,30 @@ dec_value([65 | Bytes]) ->
%% Unsigned32
dec_value([66 | Bytes]) ->
{Value, Rest} = dec_integer_notag(Bytes),
- if
- (Value >= 0) andalso (Value =< 16#ffffffff) ->
- {{'Unsigned32', Value}, Rest};
- true ->
- exit({error, {bad_unsigned32, Value}})
- end;
+ Value2 =
+ if
+ (Value >= 0) andalso (Value =< 16#ffffffff) ->
+ Value;
+ (Value < 0) ->
+ 16#ffffffff + Value + 1;
+ true ->
+ exit({error, {bad_unsigned32, Value}})
+ end,
+ {{'Unsigned32', Value2}, Rest};
%% TimeTicks
dec_value([67 | Bytes]) ->
{Value, Rest} = dec_integer_notag(Bytes),
- if
- (Value >= 0) andalso (Value =< 16#ffffffff) ->
- {{'TimeTicks', Value}, Rest};
+ Value2 =
+ if
+ (Value >= 0) andalso (Value =< 16#ffffffff) ->
+ Value;
+ (Value < 0) ->
+ 16#ffffffff + Value + 1;
true ->
exit({error, {bad_timeticks, Value}})
- end;
+ end,
+ {{'TimeTicks', Value2}, Rest};
%% Opaque
dec_value([68 | Bytes]) ->