| Differences between
and this patch
- a/WebCore/ChangeLog +12 lines
Lines 1-3 a/WebCore/ChangeLog_sec1
1
2010-04-07  Jian Li  <jianli@chromium.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Add the comment and assert to illustrate that we're generating version 4
6
        random number based UUIDs.
7
        https://bugs.webkit.org/show_bug.cgi?id=36472
8
9
        * platform/UUID.cpp:
10
        (WebCore::createCanonicalUUIDString):
11
        * platform/UUID.h:
12
1
2010-04-07  Alexey Proskuryakov  <ap@apple.com>
13
2010-04-07  Alexey Proskuryakov  <ap@apple.com>
2
14
3
        * platform/network/mac/AuthenticationMac.mm: Fix a typo in comment.
15
        * platform/network/mac/AuthenticationMac.mm: Fix a typo in comment.
- a/WebCore/platform/UUID.cpp -3 / +12 lines
Lines 46-51 a/WebCore/platform/UUID.cpp_sec1
46
46
47
namespace WebCore {
47
namespace WebCore {
48
48
49
static const char uuidVersionRequired = '4';
50
static const int uuidVersionIdentifierIndex = 14;
51
49
String createCanonicalUUIDString()
52
String createCanonicalUUIDString()
50
{
53
{
51
#if OS(WINDOWS)
54
#if OS(WINDOWS)
Lines 56-69 String createCanonicalUUIDString() a/WebCore/platform/UUID.cpp_sec2
56
    wchar_t uuidStr[40];
59
    wchar_t uuidStr[40];
57
    int num = StringFromGUID2(uuid, reinterpret_cast<LPOLESTR>(uuidStr), ARRAYSIZE(uuidStr));
60
    int num = StringFromGUID2(uuid, reinterpret_cast<LPOLESTR>(uuidStr), ARRAYSIZE(uuidStr));
58
    ASSERT(num == 39);
61
    ASSERT(num == 39);
59
    return String(uuidStr + 1, num - 3).lower(); // remove opening and closing bracket and make it lower.
62
    String canonicalUuidStr = String(uuidStr + 1, num - 3).lower(); // remove opening and closing bracket and make it lower.
63
    ASSERT(canonicalUuidStr[uuidVersionIdentifierIndex] == uuidVersionRequired);
64
    return canonicalUuidStr;
60
#elif OS(DARWIN)
65
#elif OS(DARWIN)
61
    CFUUIDRef uuid = CFUUIDCreate(0);
66
    CFUUIDRef uuid = CFUUIDCreate(0);
62
    CFStringRef uuidStrRef = CFUUIDCreateString(0, uuid);
67
    CFStringRef uuidStrRef = CFUUIDCreateString(0, uuid);
63
    String uuidStr(uuidStrRef);
68
    String uuidStr(uuidStrRef);
64
    CFRelease(uuidStrRef);
69
    CFRelease(uuidStrRef);
65
    CFRelease(uuid);
70
    CFRelease(uuid);
66
    return uuidStr.lower(); // make it lower.
71
    String canonicalUuidStr = uuidStr.lower(); // make it lower.
72
    ASSERT(canonicalUuidStr[uuidVersionIdentifierIndex] == uuidVersionRequired);
73
    return canonicalUuidStr;
67
#elif OS(LINUX)
74
#elif OS(LINUX)
68
    FILE* fptr = fopen("/proc/sys/kernel/random/uuid", "r");
75
    FILE* fptr = fopen("/proc/sys/kernel/random/uuid", "r");
69
    if (!fptr)
76
    if (!fptr)
Lines 71-77 String createCanonicalUUIDString() a/WebCore/platform/UUID.cpp_sec3
71
    char uuidStr[37] = {0};
78
    char uuidStr[37] = {0};
72
    fgets(uuidStr, sizeof(uuidStr) - 1, fptr);
79
    fgets(uuidStr, sizeof(uuidStr) - 1, fptr);
73
    fclose(fptr);
80
    fclose(fptr);
74
    return String(uuidStr).lower(); // make it lower.
81
    String canonicalUuidStr = String(uuidStr).lower(); // make it lower.
82
    ASSERT(canonicalUuidStr[uuidVersionIdentifierIndex] == uuidVersionRequired);
83
    return canonicalUuidStr;
75
#else
84
#else
76
    notImplemented();
85
    notImplemented();
77
    return String();
86
    return String();
- a/WebCore/platform/UUID.h +9 lines
Lines 38-43 namespace WebCore { a/WebCore/platform/UUID.h_sec1
38
// Creates a UUID that consists of 32 hexadecimal digits and returns its canonical form.
38
// Creates a UUID that consists of 32 hexadecimal digits and returns its canonical form.
39
// The canonical form is displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.
39
// The canonical form is displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.
40
// The hexadecimal values "a" through "f" are output as lower case characters.
40
// The hexadecimal values "a" through "f" are output as lower case characters.
41
//
42
// Note: for security reason, we should always generate version 4 UUID that use a scheme relying only on random numbers.
43
// This algorithm sets the version number as well as two reserved bits. All other bits are set using a random or pseudorandom
44
// data source. Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx with hexadecimal digits for x and one of 8,
45
// 9, A, or B for y.
46
//
47
// On Windows, version 4 UUIDs are used since Windows 2000 (http://msdn.microsoft.com/en-us/library/aa446557.aspx).
48
// On MacOSX, version 4 UUIDs are used since Tiger (http://developer.apple.com/mac/library/technotes/tn/tn1103.html#TNTAG8).
49
// On Linux, the kernel offers the procfs pseudo-file /proc/sys/kernel/random/uuid that yields versiob 4 UUIDs (http://hbfs.wordpress.com/2008/09/30/ueid-unique-enough-ids/).
41
String createCanonicalUUIDString();
50
String createCanonicalUUIDString();
42
51
43
}
52
}

Return to Bug 36472