PacketFence - BTS - PacketFence
View Issue Details
0000832PacketFencecorepublic2009-10-28 14:312012-02-29 10:58
obilodeau 
obilodeau 
normalminorhave not tried
closedfixed 
 
2.1.0 
c0cb2ad2a1b2eacec58aca67d83a7095b4e42b9a
0000832: Warning in vlan.pm around line 152
        my @upLinks = $switch->getUpLinks();
        if ( $upLinks[0] == -1 ) {

we should validate for empty array!
No tags attached.
related to 0000831closed obilodeau not careful enough when validating uplink parameter in switches.conf causes threads to hang later 
Issue History
2009-10-28 14:31obilodeauNew Issue
2009-10-28 14:31obilodeauRelationship addedrelated to 0000831
2009-10-28 14:31obilodeauStatusnew => assigned
2009-10-28 14:31obilodeauAssigned To => obilodeau
2011-01-18 11:53obilodeauTarget Version => 2.0.1
2011-01-26 15:30obilodeauTarget Version2.0.1 => 2.0.2
2011-01-27 13:28fgaudreaultNote Added: 0001836
2011-01-27 13:29fgaudreaultFile Added: vlan.pm.patch
2011-02-03 14:47obilodeauNote Added: 0001853
2011-02-03 14:47obilodeauNote Edited: 0001853
2011-02-03 14:50obilodeauNote Added: 0001854
2011-02-03 14:53obilodeauNote Added: 0001855
2011-02-03 14:55obilodeauFile Deleted: vlan.pm.patch
2011-02-03 15:05obilodeaumtn revision => c0cb2ad2a1b2eacec58aca67d83a7095b4e42b9a
2011-02-03 15:05obilodeauNote Added: 0001856
2011-02-03 15:05obilodeauStatusassigned => resolved
2011-02-03 15:05obilodeauFixed in Version => 2.0.2
2011-02-03 15:05obilodeauResolutionopen => fixed
2011-03-03 15:20obilodeauFixed in Version2.0.2 => 2.1.0
2011-03-03 15:25obilodeauStatusresolved => closed
2012-02-29 10:58obilodeauCategoryfuture => core

Notes
(0001836)
fgaudreault   
2011-01-27 13:28   
Did a patch for it, to be validated/tested.
(0001853)
obilodeau   
2011-02-03 14:47   
Reproduced issue with test cases in t/vlan.t. Two cases where the code bombs:
- not an array
- empty array

trying the patch

(0001854)
obilodeau   
2011-02-03 14:50   
the patch doesn't respect the desired behavior. A zero uplink list should return 1 and with the patch it'll return 0.

#   Failed test 'avoid empty array warning (issue \0000832)'
#   in vlan.t at line 112.
#          got: '0'
#     expected: '1'
not ok 10 - avoid empty array warning (issue \0000832)

#   Failed test 'Zero uplinks'
#   in vlan.t at line 119.
#          got: '0'
#     expected: '1'
not ok 11 - Zero uplinks

#   Failed test 'getUpLinks not supported return 0'
#   in vlan.t at line 126.
#          got: '1'
#     expected: '0'
not ok 12 - getUpLinks not supported return 0
ok 13 - do we act on uplink?
# Looks like you failed 3 tests of 14.

(0001855)
obilodeau   
2011-02-03 14:53   
fixed it. Here's the patch:

#
# old_revision [c29f24c5813973df2563988671ab3e279c219927]
#
# patch "pf/lib/pf/vlan.pm"
#  from [ba5ea5b5334a6a05b0234f7039666c40ecc9de22]
#    to [db0fbb6caa31e08eaa05674fd61d4e27fbacb061]
#
============================================================
--- pf/lib/pf/vlan.pm   ba5ea5b5334a6a05b0234f7039666c40ecc9de22
+++ pf/lib/pf/vlan.pm   db0fbb6caa31e08eaa05674fd61d4e27fbacb061
@@ -106,7 +106,7 @@ sub doWeActOnThisTrap {
     if ( ( $ifType == $SNMP::ETHERNET_CSMACD ) || ( $ifType == $SNMP::GIGABIT_ETHERNET ) ) {
         my @upLinks = $switch->getUpLinks();
         # TODO: need to validate for empty array here to avoid warning
-        if ( $upLinks[0] == -1 ) {
+        if ( @upLinks && $upLinks[0] == -1 ) {
             $logger->warn("Can't determine Uplinks for the switch -> do nothing");
         
} else {
             if ( grep( { $_ == $ifIndex } @upLinks ) == 0 ) {



Test results:
ok 10 - avoid empty array warning (issue \0000832)
ok 11 - Zero uplinks
ok 12 - getUpLinks not supported return 0
ok 13 - do we act on uplink?
ok 14 - no warnings
(0001856)
obilodeau   
2011-02-03 15:05   
fix committed