diff options
author | 2017-05-16 21:41:39 +0200 | |
---|---|---|
committer | 2017-05-17 15:21:04 +0200 | |
commit | 9e255ef45c4928eb167c1f24756cb7ab435914e5 (patch) | |
tree | c835baaf52f6d6e3278e5d4e74ef858a7d4e3f5a /src/main/java/com/google/devtools/build/lib/rules/config | |
parent | 21fd43e8b66df9d6e06dee31c1f05a8440df6342 (diff) |
Fix minor hashing bug in config_feature_flag configuration name.
Previously, it was possible to have
//package:foo : barbaz
and
//package:foobar : baz
hash to the same value, making it very easy for users to cause a hash
collision by accident. This adds a zero byte after each string so that the
hash will differentiate the two.
RELNOTES: None.
PiperOrigin-RevId: 156216723
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/config')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagConfiguration.java | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagConfiguration.java index dbb913d626..4f471e8838 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagConfiguration.java @@ -119,7 +119,9 @@ public final class ConfigFeatureFlagConfiguration extends BuildConfiguration.Fra for (Map.Entry<Label, String> flag : flagValues.entrySet()) { hasher.putUnencodedChars(flag.getKey().toString()); + hasher.putByte((byte) 0); hasher.putUnencodedChars(flag.getValue()); + hasher.putByte((byte) 0); } return hasher.hash().toString(); } |