Fossil SCM
In validate16(), refuse a zero byte before the stated length. A sync card whose hash held one passed the hash check, and an igot card then tried to store a phantom under a truncated hash.
Commit
70cae41d43c15defd107eb5f06c427d2e2eb83c2fe49c52440eec5d29d5f0cd8
Parent
8b0dbb2f3e5fba1…
1 file changed
+1
-3
+1
-3
| --- src/encode.c | ||
| +++ src/encode.c | ||
| @@ -788,13 +788,11 @@ | ||
| 788 | 788 | if( nIn<0 ) nIn = (int)strlen(zIn); |
| 789 | 789 | if( zIn[nIn]==0 ){ |
| 790 | 790 | return (int)strspn(zIn,"0123456789abcdefABCDEF")==nIn; |
| 791 | 791 | } |
| 792 | 792 | for(i=0; i<nIn; i++, zIn++){ |
| 793 | - if( zDecode[zIn[0]&0xff]>63 ){ | |
| 794 | - return zIn[0]==0; | |
| 795 | - } | |
| 793 | + if( zDecode[zIn[0]&0xff]>63 ) return 0; | |
| 796 | 794 | } |
| 797 | 795 | return 1; |
| 798 | 796 | } |
| 799 | 797 | |
| 800 | 798 | /* |
| 801 | 799 |
| --- src/encode.c | |
| +++ src/encode.c | |
| @@ -788,13 +788,11 @@ | |
| 788 | if( nIn<0 ) nIn = (int)strlen(zIn); |
| 789 | if( zIn[nIn]==0 ){ |
| 790 | return (int)strspn(zIn,"0123456789abcdefABCDEF")==nIn; |
| 791 | } |
| 792 | for(i=0; i<nIn; i++, zIn++){ |
| 793 | if( zDecode[zIn[0]&0xff]>63 ){ |
| 794 | return zIn[0]==0; |
| 795 | } |
| 796 | } |
| 797 | return 1; |
| 798 | } |
| 799 | |
| 800 | /* |
| 801 |
| --- src/encode.c | |
| +++ src/encode.c | |
| @@ -788,13 +788,11 @@ | |
| 788 | if( nIn<0 ) nIn = (int)strlen(zIn); |
| 789 | if( zIn[nIn]==0 ){ |
| 790 | return (int)strspn(zIn,"0123456789abcdefABCDEF")==nIn; |
| 791 | } |
| 792 | for(i=0; i<nIn; i++, zIn++){ |
| 793 | if( zDecode[zIn[0]&0xff]>63 ) return 0; |
| 794 | } |
| 795 | return 1; |
| 796 | } |
| 797 | |
| 798 | /* |
| 799 |