Opened 17 years ago

Closed 17 years ago

#2122 closed defect (fixed)

WMS GetCapabilities w/Nested Groups seg fault

Reported by: dmorissette Owned by: dmorissette
Priority: normal Milestone: 5.0 release
Component: WMS Server Version:
Severity: normal Keywords:
Cc: sdlime, valik.solorzano.barboza@…

Description

A user reported a seg fault when doing a GetCapabilities with nested groups and sent the following patch (sorry for the broken formatting) that apparently fixes the problem:

--- mapserver-4.10.0/mapwms.c 2006-08-24 07:44:51.000000000 -0500
+++ mapserver-4.10.0-wms/mapwms.c 2007-06-07 16:15:44.000000000
-0500
@@ -1559,17 +1559,17 @@
{
int i;
if (numOtherGroups == 0 || numOtherGroups < currentLevel)
{
return MS_FALSE;
}
/* compare all groups below the current level */
- for (i = 0; i <= currentLevel; i++)
+ for (i = 0; i < currentLevel; i++)
{
- if (strncmp(currentGroups[i], otherGroups[i],
strlen(currentGroups[i])) != 0)
+ if ((otherGroups[i] == NULL) || (strncmp(currentGroups[i],
otherGroups[i], strlen(currentGroups[i])) != 0))
{
return MS_FALSE; /* if one of these is not equal it is not a
sub group */
}
}
return MS_TRUE;
}

I'll try to get a copy of a mapfile to reproduce/test the crash.

I'll also CC Valik who wrote this code to get some feedback on the proposed fix.

Change History (3)

comment:1 by dmorissette, 17 years ago

Milestone: 5.0 release

comment:2 by dmorissette, 17 years ago

Status: newassigned

Valik, do you have any comment on the proposed patch? Does it seem right to you?

comment:3 by dmorissette, 17 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r6483 with a modified veersion of the patch.

I did more testing and found that there was also a previously existing issue in msWMSIsSubGroup() that would return a false positive in a case where currentLevel == numOtherGroups and lead to some layer being placed in the wrong level of the group hierarchy.

e.g. if we had a mapfile with layers as follows then the second layer (drain_fn) would have been incorrectly placed under /l1/l2/l3 instead of being under /l1/l2 as expected. This is fixed in r6483 as well:

LAYER
  NAME park
  METADATA
    "wms_title"    "Parks"
    "WMS_LAYER_GROUP" "/l1/l2/l3"
    ...
  END
  ...
END

LAYER
  NAME drain_fn
  METADATA
    "wms_title"  "Water"
    "WMS_LAYER_GROUP" "/l1/l2"
  END
  ...
END

LAYER
  NAME drainage
  METADATA
    "wms_title"  "Drainage"
    "WMS_LAYER_GROUP" "/l1/l2/l3"
  END
  ...
END
Note: See TracTickets for help on using tickets.