Deleting rooms: Invalid pointers; safeguarrds
authorWilfried Goesgens <dothebart@citadel.org>
Tue, 24 Apr 2012 09:51:05 +0000 (11:51 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 24 Apr 2012 09:51:05 +0000 (11:51 +0200)
  - Server return buffer wasn't allocated -> crash
  - add mandatory parameter 'go' to delete_room, so we're realy shure which room to delete.

webcit/roomops.c
webcit/static/t/room/edit/tab_admin.html

index edc09dec0eb1ca2ca74d5508a41471276217283b..09534742eeaae5ba09b01b4222c68ef64487d60d 100644 (file)
@@ -354,20 +354,30 @@ void ParseGoto(folder *room, StrBuf *Line)
  */
 void delete_room(void)
 {
-       StrBuf *Line;
+       StrBuf *Line = NewStrBuf();
+       const StrBuf *GoBstr;
        
-       serv_puts("KILL 1");
-       StrBuf_ServGetln(Line);
-       if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
-               display_main_menu();
-       } else {
-               StrBuf *Buf;
-               
-               FlushRoomlist ();
-               Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
-               smart_goto(Buf);
-               FreeStrBuf(&Buf);
+       GoBstr = sbstr("go");
+
+       if (GoBstr != NULL)
+       {
+               if (gotoroom(GoBstr) == 200)
+               {
+                       serv_puts("KILL 1");
+                       StrBuf_ServGetln(Line);
+                       if (GetServerStatusMsg(Line, NULL, 1, 2) == 2) {
+                               StrBuf *Buf;
+                               
+                               FlushRoomlist ();
+                               Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
+                               smart_goto(Buf);
+                               FreeStrBuf(&Buf);
+                               FreeStrBuf(&Line);
+                               return;
+                       }
+               }
        }
+       display_main_menu();
        FreeStrBuf(&Line);
 }
 
index 896c7ca14b09f2bdd59b95c78eb27e0adfd38363..82962de8774560c8b1cba1df27e44421a6a329ea 100644 (file)
@@ -1,7 +1,7 @@
 <div class="tabcontent">
        <ul>
                <li>
-                       <a href="delete_room" onClick="return confirm('<?_("Are you sure you want to delete this room?")>')">
+                       <a href="delete_room?go=<?THISROOM("U")>" onClick="return confirm('<?_("Are you sure you want to delete this room?")>')">
                                <?_("Delete this room")>
                        </a>
                </li>