~ubuntu-branches/ubuntu/maverick/xorg-server/maverick-security

« back to all changes in this revision

Viewing changes to Xext/sync.c

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2010-08-05 11:25:14 UTC
  • mfrom: (1.1.35 upstream) (0.1.14 experimental)
  • Revision ID: james.westby@ubuntu.com-20100805112514-q4efdgj3nblevos2
Tags: 2:1.8.99.905-1ubuntu1
* Merge from (unreleased) Debian experimental.  Remaining Ubuntu changes:
  - rules, control:
    + Disable SELinux, libaudit-dev is not in main yet (LP 406226).
      Drop libaudit-dev from build-deps.
  - rules: Enable xcsecurity (LP 247537).
  - local/xvfb-run*: Add correct docs about error codes (LP 328205)
  - rules: Add --with-extra-module-dir to support GL alternatives.
  - control: Xvfb depends on xauth, x11-xkb-utils. (LP 500102)
  - rules, local/64-xorg-xkb.rules: Don't use keyboard-configuration
    until it's available.
  - control: Update some versioned Breaks for Ubuntu versions.
  - debian/patches:
    + 100_rethrow_signals.patch:
      When aborting, re-raise signals for apport
    + 109_fix-swcursor-crash.patch:
      Avoid dereferencing null pointer while reloading cursors during
      resume. (LP 371405)
    + 111_armel-drv-fallbacks.patch:
      Add support for armel driver fallbacks.
    + 121_only_switch_vt_when_active.diff:
      Add a check to prevent the X server from changing the VT when killing
      GDM from the console.
    + 122_xext_fix_card32_overflow_in_xauth.patch:
      Fix server crash when “xauth generate” is called with large timeout.
    + 157_check_null_modes.patch, 162_null_crtc_in_rotation.patch,
      166_nullptr_xinerama_keyrepeat.patch, 167_nullptr_xisbread.patch
      169_mipointer_nullptr_checks.patch,
      172_cwgetbackingpicture_nullptr_check.patch:
      Fix various segfaults in xserver by checking pointers for NULL
      values before dereferencing them.
    + 165_man_xorg_conf_no_device_ident.patch
      Correct man page
    + 168_glibc_trace_to_stderr.patch:
      Report abort traces to stderr instead of terminal
    + 184_virtual_devices_autodetect.patch:
      Use vesa for qemu device, which is not supported by cirrus
    + 187_edid_quirk_hp_nc8430.patch:
      Quirk for another LPL monitor (LP 380009)
    + 188_default_primary_to_first_busid.patch:
      Pick the first device and carry on (LP 459512)
    + 189_xserver_1.5.0_bg_none_root.patch:
      Create a root window with no background.
    + 190_cache-xkbcomp_output_for_fast_start_up.patch:
      Cache keyboard settings.
    + 191-Xorg-add-an-extra-module-path.patch:
      Add support for the alternatives module path.
    + 197_xvfb-randr.patch:
      Adds xrandr support to xvfb. (LP 516123)
    + 198_nohwaccess.patch:
      Adds a -nohwaccess argument to make X not access the hardware
      ports directly.
    + 200_randr-null.patch:
      Clarify a pointer initialization.
* Update changelog entries for 1.8.1.902-1 which became 1.8.99.904-1
* Drop 196_xvfbscreeninit-handling.patch: it's semantically empty, and now 
  doesn't apply.  Merge remaining #include change into 197_xvfb-randr.patch
* New upstream version will start correctly when no outputs are connected,
  as long as the video driver can dynamically resize the framebuffer
  (true for all KMS drivers) (LP: #337889)
* New upstream version fixes crash on non-admin logout with KDE (LP: #569879)
* Refresh 111_armel-drv-fallbacks.patch to fix the build on armel

Show diffs side-by-side

added added

removed removed

Lines of Context:
158
158
            else
159
159
                pTrigger->pCounter->pTriglist = pCur->next;
160
160
 
161
 
            xfree(pCur);
 
161
            free(pCur);
162
162
            break;
163
163
        }
164
164
        
186
186
            return Success;
187
187
    }
188
188
 
189
 
    if (!(pCur = xalloc(sizeof(SyncTriggerList))))
 
189
    if (!(pCur = malloc(sizeof(SyncTriggerList))))
190
190
        return BadAlloc;
191
191
 
192
192
    pCur->pTrigger = pTrigger;
264
264
                                counter, RTCounter, client, DixReadAccess)))
265
265
        {
266
266
            client->errorValue = counter;
267
 
            return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
 
267
            return rc;
268
268
        }
269
269
        if (pCounter != pTrigger->pCounter)
270
270
        { /* new counter for trigger */
372
372
 
373
373
    ane.type = SyncEventBase + XSyncAlarmNotify;
374
374
    ane.kind = XSyncAlarmNotify;
375
 
    ane.sequenceNumber = pAlarm->client->sequence;
376
375
    ane.alarm = pAlarm->alarm_id;
377
376
    if (pTrigger->pCounter)
378
377
    {
390
389
    ane.state = pAlarm->state;
391
390
 
392
391
    /* send to owner */
393
 
    if (pAlarm->events && !pAlarm->client->clientGone)
 
392
    if (pAlarm->events)
394
393
        WriteEventsToClient(pAlarm->client, 1, (xEvent *) &ane);
395
394
 
396
395
    /* send to other interested clients */
397
396
    for (pcl = pAlarm->pEventClients; pcl; pcl = pcl->next)
398
 
    {
399
 
        if (!pAlarm->client->clientGone)
400
 
        {
401
 
            ane.sequenceNumber = pcl->client->sequence;
402
 
            WriteEventsToClient(pcl->client, 1, (xEvent *) &ane);
403
 
        }
404
 
    }
 
397
        WriteEventsToClient(pcl->client, 1, (xEvent *) &ane);
405
398
}
406
399
 
407
400
 
417
410
 
418
411
    if (client->clientGone)
419
412
        return;
420
 
    pev = pEvents = xalloc(num_events * sizeof(xSyncCounterNotifyEvent));
 
413
    pev = pEvents = malloc(num_events * sizeof(xSyncCounterNotifyEvent));
421
414
    if (!pEvents)
422
415
        return;
423
416
    UpdateCurrentTime();
426
419
        SyncTrigger *pTrigger = &(*ppAwait)->trigger;
427
420
        pev->type = SyncEventBase + XSyncCounterNotify;
428
421
        pev->kind = XSyncCounterNotify;
429
 
        pev->sequenceNumber = client->sequence;
430
422
        pev->counter = pTrigger->pCounter->id;
431
423
        pev->wait_value_lo = XSyncValueLow32(pTrigger->test_value);
432
424
        pev->wait_value_hi = XSyncValueHigh32(pTrigger->test_value);
438
430
    }
439
431
    /* swapping will be taken care of by this */
440
432
    WriteEventsToClient(client, num_events, (xEvent *)pEvents);
441
 
    xfree(pEvents);
 
433
    free(pEvents);
442
434
}
443
435
 
444
436
 
545
537
 
546
538
    pAwaitUnion = (SyncAwaitUnion *)pAwait->pHeader;
547
539
    numwaits = pAwaitUnion->header.num_waitconditions;
548
 
    ppAwait = xalloc(numwaits * sizeof(SyncAwait *));
 
540
    ppAwait = malloc(numwaits * sizeof(SyncAwait *));
549
541
    if (!ppAwait)
550
542
        goto bail;
551
543
 
614
606
    if (num_events)
615
607
        SyncSendCounterNotifyEvents(pAwaitUnion->header.client, ppAwait,
616
608
                                    num_events);
617
 
    xfree(ppAwait);
 
609
    free(ppAwait);
618
610
 
619
611
bail:
620
612
    /* unblock the client */
695
687
 
696
688
    /* add new client to pAlarm->pEventClients */
697
689
 
698
 
    pClients = xalloc(sizeof(SyncAlarmClientList));
 
690
    pClients = malloc(sizeof(SyncAlarmClientList));
699
691
    if (!pClients)
700
692
        return BadAlloc;
701
693
 
706
698
    pClients->delete_id = FakeClientID(client->index);
707
699
    if (!AddResource(pClients->delete_id, RTAlarmClient, pAlarm))
708
700
    {
709
 
        xfree(pClients);
 
701
        free(pClients);
710
702
        return BadAlloc;
711
703
    }
712
704
 
824
816
{
825
817
    SyncCounter *pCounter;
826
818
 
827
 
    if (!(pCounter = xalloc(sizeof(SyncCounter))))
 
819
    if (!(pCounter = malloc(sizeof(SyncCounter))))
828
820
        return NULL;
829
821
 
830
822
    if (!AddResource(id, RTCounter, (pointer) pCounter))
831
823
    {
832
 
        xfree(pCounter);
 
824
        free(pCounter);
833
825
        return NULL;
834
826
    }
835
827
 
863
855
{
864
856
    SyncCounter    *pCounter;
865
857
 
866
 
    SysCounterList = xrealloc(SysCounterList,
 
858
    SysCounterList = realloc(SysCounterList,
867
859
                            (SyncNumSystemCounters+1)*sizeof(SyncCounter *));
868
860
    if (!SysCounterList)
869
861
        return NULL;
886
878
    {
887
879
        SysCounterInfo *psci;
888
880
 
889
 
        psci = xalloc(sizeof(SysCounterInfo));
 
881
        psci = malloc(sizeof(SysCounterInfo));
890
882
        if (!psci)
891
883
        {
892
884
            FreeResource(pCounter->id, RT_NONE);
1008
1000
 
1009
1001
    SyncDeleteTriggerFromCounter(&pAlarm->trigger);
1010
1002
 
1011
 
    xfree(pAlarm);
 
1003
    free(pAlarm);
1012
1004
    return Success;
1013
1005
}
1014
1006
 
1029
1021
    {
1030
1022
        (*ptl->pTrigger->CounterDestroyed)(ptl->pTrigger);
1031
1023
        pnext = ptl->next;
1032
 
        xfree(ptl); /* destroy the trigger list as we go */
 
1024
        free(ptl); /* destroy the trigger list as we go */
1033
1025
    }
1034
1026
    if (IsSystemCounter(pCounter))
1035
1027
    {
1036
1028
        int i, found = 0;
1037
1029
 
1038
 
        xfree(pCounter->pSysCounterInfo);
 
1030
        free(pCounter->pSysCounterInfo);
1039
1031
 
1040
1032
        /* find the counter in the list of system counters and remove it */
1041
1033
 
1059
1051
        }
1060
1052
        SyncNumSystemCounters--;
1061
1053
    }
1062
 
    xfree(pCounter);
 
1054
    free(pCounter);
1063
1055
    return Success;
1064
1056
}
1065
1057
 
1088
1080
        if (pCounter && !pCounter->beingDestroyed)
1089
1081
            SyncDeleteTriggerFromCounter(&pAwait->trigger);
1090
1082
    }
1091
 
    xfree(pAwaitUnion);
 
1083
    free(pAwaitUnion);
1092
1084
    return Success;
1093
1085
}
1094
1086
 
1109
1101
                pPrev->next = pCur->next;
1110
1102
            else
1111
1103
                pAlarm->pEventClients = pCur->next;
1112
 
            xfree(pCur);
 
1104
            free(pCur);
1113
1105
            return Success;
1114
1106
        }
1115
1107
    }
1146
1138
        swaps(&rep.sequenceNumber, n);
1147
1139
    }
1148
1140
    WriteToClient(client, sizeof(rep), (char *) &rep);
1149
 
    return client->noClientException;
 
1141
    return Success;
1150
1142
}
1151
1143
 
1152
1144
/*
1174
1166
 
1175
1167
    if (len)
1176
1168
    {
1177
 
        walklist = list = xalloc(len);
 
1169
        walklist = list = malloc(len);
1178
1170
        if (!list)
1179
1171
            return BadAlloc;
1180
1172
    }
1220
1212
    if (len)
1221
1213
    {
1222
1214
        WriteToClient(client, len, (char *) list);
1223
 
        xfree(list);
 
1215
        free(list);
1224
1216
    }
1225
1217
 
1226
 
    return client->noClientException;
 
1218
    return Success;
1227
1219
}
1228
1220
 
1229
1221
/*
1297
1289
 
1298
1290
    WriteToClient(client, sizeof(xSyncGetPriorityReply), (char *) &rep);
1299
1291
 
1300
 
    return client->noClientException;
 
1292
    return Success;
1301
1293
}
1302
1294
 
1303
1295
/*
1317
1309
    if (!SyncCreateCounter(client, stuff->cid, initial))
1318
1310
        return BadAlloc;
1319
1311
 
1320
 
    return client->noClientException;
 
1312
    return Success;
1321
1313
}
1322
1314
 
1323
1315
/*
1336
1328
    rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
1337
1329
                                 client, DixWriteAccess);
1338
1330
    if (rc != Success)
1339
 
        return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
 
1331
        return rc;
1340
1332
 
1341
1333
    if (IsSystemCounter(pCounter))
1342
1334
    {
1366
1358
    rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
1367
1359
                                 client, DixWriteAccess);
1368
1360
    if (rc != Success)
1369
 
        return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
 
1361
        return rc;
1370
1362
 
1371
1363
    if (IsSystemCounter(pCounter))
1372
1364
    {
1401
1393
    rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter,
1402
1394
                                 client, DixDestroyAccess);
1403
1395
    if (rc != Success)
1404
 
        return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
 
1396
        return rc;
1405
1397
 
1406
1398
    if (IsSystemCounter(pCounter))
1407
1399
    {
1448
1440
    /*  all the memory for the entire await list is allocated
1449
1441
     *  here in one chunk
1450
1442
     */
1451
 
    pAwaitUnion = xalloc((items+1) * sizeof(SyncAwaitUnion));
 
1443
    pAwaitUnion = malloc((items+1) * sizeof(SyncAwaitUnion));
1452
1444
    if (!pAwaitUnion)
1453
1445
        return BadAlloc;
1454
1446
 
1457
1449
    pAwaitUnion->header.delete_id = FakeClientID(client->index);
1458
1450
    if (!AddResource(pAwaitUnion->header.delete_id, RTAwait, pAwaitUnion))
1459
1451
    {
1460
 
        xfree(pAwaitUnion);
 
1452
        free(pAwaitUnion);
1461
1453
        return BadAlloc;
1462
1454
    }
1463
1455
 
1544
1536
    rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter,
1545
1537
                                 RTCounter, client, DixReadAccess);
1546
1538
    if (rc != Success)
1547
 
        return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
 
1539
        return rc;
1548
1540
 
1549
1541
    rep.type = X_Reply;
1550
1542
    rep.length = 0;
1569
1561
        swapl(&rep.value_lo, n);
1570
1562
    }
1571
1563
    WriteToClient(client, sizeof(xSyncQueryCounterReply), (char *) &rep);
1572
 
    return client->noClientException;
 
1564
    return Success;
1573
1565
}
1574
1566
 
1575
1567
 
1595
1587
    if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
1596
1588
        return BadLength;
1597
1589
 
1598
 
    if (!(pAlarm = xalloc(sizeof(SyncAlarm))))
 
1590
    if (!(pAlarm = malloc(sizeof(SyncAlarm))))
1599
1591
    {
1600
1592
        return BadAlloc;
1601
1593
    }
1612
1604
    status = SyncInitTrigger(client, pTrigger, None, XSyncCAAllTrigger);
1613
1605
    if (status != Success)
1614
1606
    {
1615
 
        xfree(pAlarm);
 
1607
        free(pAlarm);
1616
1608
        return status;
1617
1609
    }
1618
1610
 
1626
1618
                                       (CARD32 *)&stuff[1]);
1627
1619
    if (status != Success)
1628
1620
    {
1629
 
        xfree(pAlarm);
 
1621
        free(pAlarm);
1630
1622
        return status;
1631
1623
    }
1632
1624
 
1633
1625
    if (!AddResource(stuff->id, RTAlarm, pAlarm))
1634
1626
    {
1635
 
        xfree(pAlarm);
 
1627
        free(pAlarm);
1636
1628
        return BadAlloc;
1637
1629
    }
1638
1630
 
1668
1660
    status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
1669
1661
                                     client, DixWriteAccess);
1670
1662
    if (status != Success)
1671
 
        return (status == BadValue) ? SyncErrorBase + XSyncBadAlarm : status;
 
1663
        return status;
1672
1664
 
1673
1665
    vmask = stuff->valueMask;
1674
1666
    len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq));
1707
1699
    rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
1708
1700
                                 client, DixReadAccess);
1709
1701
    if (rc != Success)
1710
 
        return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
 
1702
        return rc;
1711
1703
 
1712
1704
    rep.type = X_Reply;
1713
1705
    rep.length = bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply));
1749
1741
    }
1750
1742
 
1751
1743
    WriteToClient(client, sizeof(xSyncQueryAlarmReply), (char *) &rep);
1752
 
    return client->noClientException;
 
1744
    return Success;
1753
1745
}
1754
1746
 
1755
1747
static int
1764
1756
    rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
1765
1757
                                 client, DixDestroyAccess);
1766
1758
    if (rc != Success)
1767
 
        return (rc == BadValue) ? SyncErrorBase + XSyncBadAlarm : rc;
 
1759
        return rc;
1768
1760
 
1769
1761
    FreeResource(stuff->alarm, RT_NONE);
1770
 
    return client->noClientException;
 
1762
    return Success;
1771
1763
}
1772
1764
 
1773
1765
/*
2091
2083
static void
2092
2084
SyncResetProc(ExtensionEntry *extEntry)
2093
2085
{
2094
 
    xfree(SysCounterList);
 
2086
    free(SysCounterList);
2095
2087
    SysCounterList = NULL;
2096
2088
    RTCounter = 0;
2097
2089
}
2135
2127
    EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent;
2136
2128
    EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent;
2137
2129
 
 
2130
    SetResourceTypeErrorValue(RTCounter, SyncErrorBase + XSyncBadCounter);
 
2131
    SetResourceTypeErrorValue(RTAlarm, SyncErrorBase + XSyncBadAlarm);
 
2132
 
2138
2133
    /*
2139
2134
     * Although SERVERTIME is implemented by the OS layer, we initialise it
2140
2135
     * here because doing it in OsInit() is too early. The resource database
2171
2166
 
2172
2167
/*
2173
2168
*** Server Block Handler
2174
 
*** code inspired by multibuffer extension
 
2169
*** code inspired by multibuffer extension (now deprecated)
2175
2170
 */
2176
2171
/*ARGSUSED*/
2177
2172
static void