Changeset 164179 in webkit


Ignore:
Timestamp:
Feb 15, 2014 1:15:49 PM (10 years ago)
Author:
rakuco@webkit.org
Message:

[EFL][WK2] Stop calling mktemp(3).
https://bugs.webkit.org/show_bug.cgi?id=128826

Reviewed by Gyuyoung Kim.

mktemp(3) is an insecure function and should be avoided at all costs.
Replace its usage with mkdtemp(3): instead of just getting a file name
that is supposed to be random and unused, we now create a directory
with a random name and then put whatever files we need there with fixed
names.

  • UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp:

(TEST_F):

  • UIProcess/API/efl/tests/test_ewk2_download_job.cpp:

(TEST_F):

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r164172 r164179  
     12014-02-15  Raphael Kubo da Costa  <raphael.kubo.da.costa@intel.com>
     2
     3        [EFL][WK2] Stop calling mktemp(3).
     4        https://bugs.webkit.org/show_bug.cgi?id=128826
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        mktemp(3) is an insecure function and should be avoided at all costs.
     9        Replace its usage with mkdtemp(3): instead of just getting a file name
     10        that is supposed to be random and unused, we now create a directory
     11        with a random name and then put whatever files we need there with fixed
     12        names.
     13
     14        * UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp:
     15        (TEST_F):
     16        * UIProcess/API/efl/tests/test_ewk2_download_job.cpp:
     17        (TEST_F):
     18
    1192014-02-15  Dan Bernstein  <mitz@apple.com>
    220
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp

    r161139 r164179  
    2323#include "UnitTestUtils/EWK2UnitTestBase.h"
    2424#include "UnitTestUtils/EWK2UnitTestServer.h"
     25#include <stdio.h>
    2526#include <stdlib.h>
    2627#include <unistd.h>
     
    200201
    201202    // Make sure we don't get notifications when loading setting an existing persistent storage
    202     char textStorage1[] = "/tmp/txt-cookie.XXXXXX";
    203     ASSERT_TRUE(mktemp(textStorage1));
    204     char textStorage2[] = "/tmp/txt-cookie.XXXXXX";
    205     ASSERT_TRUE(mktemp(textStorage2));
     203    char storageDirectory[] = "/tmp/ewk2_cookie_manager-XXXXXX";
     204    ASSERT_TRUE(mkdtemp(storageDirectory));
     205    char textStorage1[64];
     206    snprintf(textStorage1, sizeof(textStorage1), "%s/txt-cookie1", storageDirectory);
     207    char textStorage2[64];
     208    snprintf(textStorage2, sizeof(textStorage2), "%s/txt-cookie2", storageDirectory);
    206209
    207210    ewk_cookie_manager_persistent_storage_set(cookieManager, textStorage1, EWK_COOKIE_PERSISTENT_STORAGE_TEXT);
     
    222225    unlink(textStorage1);
    223226    unlink(textStorage2);
     227    rmdir(storageDirectory);
    224228}
    225229
     
    266270
    267271    // Generate unique names for cookie storages.
    268     char textStorage[] = "/tmp/txt-cookie.XXXXXX";
    269     ASSERT_TRUE(mktemp(textStorage));
    270     char sqliteStorage[] = "/tmp/sqlite-cookie.XXXXXX";
    271     ASSERT_TRUE(mktemp(sqliteStorage));
     272    char storageDirectory[] = "/tmp/ewk2_cookie_manager-XXXXXX";
     273    ASSERT_TRUE(mkdtemp(storageDirectory));
     274    char textStorage[64];
     275    snprintf(textStorage, sizeof(textStorage), "%s/txt-cookie", storageDirectory);
     276    char sqliteStorage[64];
     277    snprintf(sqliteStorage, sizeof(sqliteStorage), "%s/sqlite-cookie", storageDirectory);
    272278
    273279    Ewk_Cookie_Manager* cookieManager = ewk_context_cookie_manager_get(ewk_view_context_get(webView()));
     
    306312    unlink(textStorage);
    307313    unlink(sqliteStorage);
     314    rmdir(storageDirectory);
    308315}
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_download_job.cpp

    r159190 r164179  
    3030#include <sys/stat.h>
    3131#include <sys/types.h>
     32#include <stdio.h>
     33#include <stdlib.h>
    3234#include <unistd.h>
    3335
     
    153155    httpServer->run(serverCallback);
    154156
    155     // Generate unique name for destination file.
    156     char destinationPath[] = "/tmp/pdf-file.XXXXXX";
    157     ASSERT_TRUE(mktemp(destinationPath));
     157    CString fileUrl = httpServer->getURLForPath(testFilePath);
    158158
    159     CString fileUrl = httpServer->getURLForPath(testFilePath);
     159    char destinationDirectory[] = "/tmp/ewk2_download_job-XXXXXX";
     160    ASSERT_TRUE(mkdtemp(destinationDirectory));
     161    char destinationPath[64];
     162    snprintf(destinationPath, sizeof(destinationPath), "%s/pdf-file", destinationDirectory);
    160163
    161164    DownloadTestData userData = { fileUrl.data(), destinationPath };
     
    173176    // Clean up
    174177    unlink(destinationPath);
     178    rmdir(destinationDirectory);
    175179}
Note: See TracChangeset for help on using the changeset viewer.