Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed flaw in uuid generation . . . #519

Closed
wants to merge 1 commit into from
Closed

Fixed flaw in uuid generation . . . #519

wants to merge 1 commit into from

Conversation

@meawoppl
Copy link
Contributor

@meawoppl meawoppl commented Dec 2, 2012

where a "&" between an integer and string gives the improper result for characters a-f.

View commit message in monospaced font to see error.

…o integer give the improper result for characters a-f.

See below for related snippet, spaced to make reading easyX marks the spot!:
>  s
["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]

>  _.map(s, function(input) { return ((input & 0x3)| 0x8)})
[ 8,   9,   10,  11,  8,   9,   10,  11,  8,   9,   8,   8,   8,   8,   8,   8]
                                                    X,   X,        X,   X,   X
_.map(s, function(input) { return ((parseInt(input,16) & 0x3)| 0x8)})
> [8,  9,   10,  11,  8,   9,   10,  11,  8,   9,   10,  11,  8,   9,   10, 11]
@@ -112,7 +112,7 @@ LocalCollection.uuid = function () {
s[i] = hexDigits.substr(Math.floor(LocalCollection.random() * 0x10), 1);
}
s[14] = "4";
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
s[19] = hexDigits.substr((parseInt(s[19],16) & 0x3) | 0x8, 1);

This comment has been minimized.

@meawoppl

meawoppl Dec 2, 2012
Author Contributor

Don't ask me how I came across this one . . .

@glasser
Copy link
Member

@glasser glasser commented Dec 2, 2012

Heh, I actually noticed this a while ago and forgot to fix it! Thanks! I applied the same fix to the uuid package (we should really not have two copies of this code...)

@glasser glasser closed this Dec 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants