diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-09-28 20:39:09 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-28 20:41:05 -0400 |
commit | 6129ff320e6510a453922dba01163824923bc782 (patch) | |
tree | 59867adf2fffea55fa8d6ff8e8d46d20476fb668 /src/config | |
parent | 6b155dc1a6c7c7bd345514a31288c260e4588216 (diff) | |
download | tor-6129ff320e6510a453922dba01163824923bc782.tar.gz tor-6129ff320e6510a453922dba01163824923bc782.zip |
Use SHL{8,32,64} in ed25519/ref10 to avoid left-shifting negative values
This helps us avoid undefined behavior. It's based on a patch from teor,
except that I wrote a perl script to regenerate the patch:
#!/usr/bin/perl -p -w -i
BEGIN { %vartypes = (); }
if (/^[{}]/) {
%vartypes = ();
}
if (/^ *crypto_int(\d+) +([a-zA-Z_][_a-zA-Z0-9]*)/) {
$vartypes{$2} = $1;
} elsif (/^ *(?:signed +)char +([a-zA-Z_][_a-zA-Z0-9]*)/) {
$vartypes{$1} = '8';
}
# This fixes at most one shift per line. But that's all the code does.
if (/([a-zA-Z_][a-zA-Z_0-9]*) *<< *(\d+)/) {
$v = $1;
if (exists $vartypes{$v}) {
s/$v *<< *(\d+)/SHL$vartypes{$v}($v,$1)/;
}
}
# remove extra parenthesis
s/\(SHL64\((.*)\)\)/SHL64\($1\)/;
s/\(SHL32\((.*)\)\)/SHL32\($1\)/;
s/\(SHL8\((.*)\)\)/SHL8\($1\)/;
Diffstat (limited to 'src/config')
0 files changed, 0 insertions, 0 deletions