RWHO command uses new function to read the context list safely.
authorDave West <davew@uncensored.citadel.org>
Tue, 18 Mar 2008 14:59:28 +0000 (14:59 +0000)
committerDave West <davew@uncensored.citadel.org>
Tue, 18 Mar 2008 14:59:28 +0000 (14:59 +0000)
citadel/modules/rwho/serv_rwho.c

index 06f439081aa4c69fb9b631233bc5ca2f3b995d35..515c5f6afa7f14e79480fbeed05c139346b3ceb1 100644 (file)
@@ -68,8 +68,7 @@ void cmd_rwho(char *argbuf) {
         */
        
 
-       nContexts = num_sessions;
-       nptr = malloc(sizeof(struct CitContext) * nContexts);
+       nptr = CtdlGetContextArray(&nContexts) ;
        if (!nptr)
        {
                /* Couldn't malloc so we have to bail but stick to the protocol */
@@ -77,12 +76,6 @@ void cmd_rwho(char *argbuf) {
                cprintf("000\n");
                return;
        }
-       begin_critical_section(S_SESSION_TABLE);
-       for (cptr = ContextList, i=0; cptr != NULL && i < nContexts; cptr = cptr->next, i++)
-       {
-               memcpy(&nptr[i], cptr, sizeof (struct CitContext));
-       }
-       end_critical_section (S_SESSION_TABLE);
        
        aide = CC->user.axlevel >= 6;
        cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress() );