serv_expire: abort() if any malloc() calls fail.
authorArt Cancro <ajc@citadel.org>
Wed, 6 Sep 2023 23:07:24 +0000 (19:07 -0400)
committerArt Cancro <ajc@citadel.org>
Wed, 6 Sep 2023 23:07:24 +0000 (19:07 -0400)
This is drastic, but the alternative is to purge records that are still good.

citadel/server/modules/expire/serv_expire.c

index 48f76b8f25a438877dec5c099901808f82e929d9..fb00e3d64a7f9cc0cbed51fcaa12a528b0c8a901 100644 (file)
@@ -209,6 +209,7 @@ void AddValidUser(char *username, void *data) {
        }
 
        vuptr = (struct ValidUser *)malloc(sizeof(struct ValidUser));
+       if (!vuptr) abort();
        vuptr->next = ValidUserList;
        vuptr->vu_usernum = usbuf.usernum;
        ValidUserList = vuptr;
@@ -219,6 +220,7 @@ void AddValidRoom(struct ctdlroom *qrbuf, void *data) {
        struct ValidRoom *vrptr;
 
        vrptr = (struct ValidRoom *)malloc(sizeof(struct ValidRoom));
+       if (!vrptr) abort();
        vrptr->next = ValidRoomList;
        vrptr->vr_roomnum = qrbuf->QRnumber;
        vrptr->vr_roomgen = qrbuf->QRgen;
@@ -268,6 +270,7 @@ void DoPurgeRooms(struct ctdlroom *qrbuf, void *data) {
 
        if (do_purge) {
                pptr = (struct PurgeList *) malloc(sizeof(struct PurgeList));
+               if (!pptr) abort();
                pptr->next = RoomPurgeList;
                strcpy(pptr->name, qrbuf->QRname);
                RoomPurgeList = pptr;
@@ -398,6 +401,7 @@ void do_user_purge(char *username, void *data) {
 
        if (purge == 1) {
                pptr = (struct PurgeList *) malloc(sizeof(struct PurgeList));
+               if (!pptr) abort();
                pptr->next = UserPurgeList;
                strcpy(pptr->name, us.fullname);
                UserPurgeList = pptr;
@@ -528,6 +532,7 @@ int PurgeVisits(void) {
                // Put the record on the purge list if it's dead
                if ((RoomIsValid==0) || (UserIsValid==0)) {
                        vptr = (struct VPurgeList *) malloc(sizeof(struct VPurgeList));
+                       if (!vptr) abort();
                        vptr->next = VisitPurgeList;
                        vptr->vp_roomnum = vbuf.v_roomnum;
                        vptr->vp_roomgen = vbuf.v_roomgen;
@@ -636,10 +641,12 @@ int PurgeEuidIndexTable(void) {
                }
                else {
                        eptr = (struct EPurgeList *) malloc(sizeof(struct EPurgeList));
+                       if (!eptr) abort();
                        if (eptr != NULL) {
                                eptr->next = el;
                                eptr->ep_keylen = cdbei.val.len - sizeof(long);
                                eptr->ep_key = malloc(cdbei.val.len);
+                               if (!eptr->ep_key) abort();
                                memcpy(eptr->ep_key, &cdbei.val.ptr[sizeof(long)], eptr->ep_keylen);
                                el = eptr;
                        }