aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Webserver crash on unexistant image file  (Read 2219 times)

Ju1i3n

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
Webserver crash on unexistant image file
« on: February 22, 2007, 12:29:50 PM »

amuleweb crashes if requesting an unexistant image file, here toto.png.

12:21:28: Erreur : impossible d'ouvrir le fichier « /home/ju1i3n/.aMule/webserver/toto.png » (erreur 2 : Aucun fichier ou répertoire de ce type)
CFileImage: failed to open /home/jdusser/.aMule/webserver/toto.png

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1244824688 (LWP 13159)]
0x0805ef30 in CScriptWebServer::ProcessImgFileReq (this=0x8195f40, Data=@0xb5cd71d0) at WebServer.cpp:292
292                     unsigned char* img_data = img->RequestData(img_size);

(gdb) bt
#0  0x0805ef30 in CScriptWebServer::ProcessImgFileReq (this=0x8195f40, Data=@0xb5cd71d0) at WebServer.cpp:292
#1  0x0808897a in CWebSocket::OnRequestReceived (this=0x81a2620,
    pHeader=0x81a27b6 "HTTP/1.1\r\nHost: localhost:5000\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.8.1.1) Gecko/20061208 Firefox/2.0.0.1\r\nAccept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text"..., pData=0x0, dwDataLen=0) at WebSocket.cpp:373
#2  0x080891c9 in CWCThread::Entry (this=0x81a2610) at WebSocket.cpp:240
#3  0xb7e2dd79 in wxThreadInternal::PthreadStart () from /usr/lib/libwx_baseu-2.6.so.0
#4  0xb7e2ddfb in wxPthreadStart () from /usr/lib/libwx_baseu-2.6.so.0
#5  0xb7ee84bb in start_thread () from /lib/libpthread.so.0
#6  0xb7b079ce in clone () from /lib/libc.so.6
(gdb) print img
$1 = (CAnyImage *) 0x0


It seems there's no test to know if img is null.


in webserver.cpp
void CScriptWebServer::ProcessImgFileReq(ThreadData Data)
{
        webInterface->DebugShow(wxT("**** imgrequest: ") + Data.sURL + wxT("\n"));
        wxMutexLocker lock(m_mutexChildren);

        const CSession* session = CheckLoggedin(Data);

        // To prevent access to non-template images, we disallow use of paths in filenames.
        wxString imgName = wxFileName::GetPathSeparator() + wxFileName(Data.parsedURL.File()).GetFullName();
        CAnyImage *img = m_ImageLib.GetImage(imgName);

        // Only static images are available to visitors, in order to prevent
        // information leakage, but still allowing images on the login page.
        if (session->m_loggedin or dynamic_cast<CFileImage*>(img)) {
                int img_size = 0;
                unsigned char* img_data = img->RequestData(img_size);
                // This unicode2char is ok.
                Data.pSocket->SendContent(unicode2char(img->GetHTTP()), img_data, img_size);
        } else if (not session->m_loggedin) {
                webInterface->DebugShow(wxT("**** imgrequest: failed, not logged in\n"));
                ProcessURL(Data);
        } else {
                webInterface->DebugShow(wxT("**** imgrequest: failed\n"));
        }
}

aMule-CVS-20070222.tar.bz2
wx-config --version: 2.6.3

« Last Edit: February 22, 2007, 12:33:10 PM by Ju1i3n »
Logged

phoenix

  • Evil respawning bird from aMule Dev Team
  • Developer
  • Hero Member
  • *****
  • Karma: 44
  • Offline Offline
  • Posts: 2503
  • The last shadow you'll ever see
Re: Webserver crash on unexistant image file
« Reply #1 on: February 23, 2007, 03:45:05 AM »

Thank you for your report!

This issue will be fixed in tomorrow's cvs tarball.
Logged