~ubuntu-branches/ubuntu/utopic/suricata/utopic

« back to all changes in this revision

Viewing changes to src/detect-engine-port.c

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2011-07-27 08:20:25 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110727082025-bm6nrhrijpmmt2xt
Tags: 1.0.5-1
ImportedĀ UpstreamĀ versionĀ 1.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1237
1237
 
1238
1238
            r = DetectPortCmp(ag, ag2);
1239
1239
            if (r == PORT_EQ || r == PORT_EB) { /* XXX more ??? */
1240
 
                if (ag2->prev == NULL) {
 
1240
                if (ag2->prev == NULL || ag2 == *head) {
1241
1241
                    *head = ag2->next;
1242
1242
                } else {
1243
1243
                    ag2->prev->next = ag2->next;
1318
1318
 * \retval NULL on error
1319
1319
 */
1320
1320
DetectPort *PortParse(char *str) {
1321
 
    char *portdup = SCStrdup(str);
 
1321
    char *portdup = NULL;
1322
1322
    char *port2 = NULL;
1323
1323
    DetectPort *dp = NULL;
 
1324
    char *port = NULL;
 
1325
 
 
1326
    if (str == NULL || strlen(str) == 0)
 
1327
        return NULL;
 
1328
 
 
1329
    portdup = SCStrdup(str);
 
1330
    if (portdup == NULL) {
 
1331
        goto error;
 
1332
    }
1324
1333
 
1325
1334
    dp = DetectPortInit();
1326
1335
    if (dp == NULL)
1327
1336
        goto error;
1328
1337
 
1329
 
    /* XXX better input validation */
1330
 
 
1331
1338
    /* we dup so we can put a nul-termination in it later */
1332
 
    char *port = portdup;
1333
 
    if (port == NULL) {
1334
 
        goto error;
1335
 
    }
 
1339
    port = portdup;
1336
1340
 
1337
1341
    /* handle the negation case */
1338
1342
    if (port[0] == '!') {
1381
1385
    if (dp != NULL)
1382
1386
        DetectPortCleanupList(dp);
1383
1387
 
1384
 
    if (portdup) SCFree(portdup);
 
1388
    if (portdup)
 
1389
        SCFree(portdup);
1385
1390
    return NULL;
1386
1391
}
1387
1392