Fossil SCM
In vxprintf(), do not read a %s argument past the number of bytes given as its precision. The whole string was measured before the precision was applied, so %.*s on a buffer with no terminator, as in the certificate prompt of ssl_open_client(), read past the end of the buffer.
Commit
da1ce17a27a73640b0af17a74fc3d8e519670b7a2d84a48ca6547e90a3d8482b
Parent
34e92f7340e01b8…
1 file changed
+1
-1
+1
-1
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -728,12 +728,12 @@ | ||
| 728 | 728 | }else if( xtype==etDYNSTRING ){ |
| 729 | 729 | zExtra = bufpt; |
| 730 | 730 | }else if( xtype==etSTRINGID ){ |
| 731 | 731 | precision = hash_digits(flag_altform2); |
| 732 | 732 | } |
| 733 | + if( limit<0 || (precision>=0 && precision<limit) ) limit = precision; | |
| 733 | 734 | length = StrNLen32(bufpt, limit); |
| 734 | - if( precision>=0 && precision<length ) length = precision; | |
| 735 | 735 | break; |
| 736 | 736 | } |
| 737 | 737 | case etBLOB: { |
| 738 | 738 | int limit = flag_alternateform ? va_arg(ap, int) : -1; |
| 739 | 739 | Blob *pBlob = va_arg(ap, Blob*); |
| 740 | 740 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -728,12 +728,12 @@ | |
| 728 | }else if( xtype==etDYNSTRING ){ |
| 729 | zExtra = bufpt; |
| 730 | }else if( xtype==etSTRINGID ){ |
| 731 | precision = hash_digits(flag_altform2); |
| 732 | } |
| 733 | length = StrNLen32(bufpt, limit); |
| 734 | if( precision>=0 && precision<length ) length = precision; |
| 735 | break; |
| 736 | } |
| 737 | case etBLOB: { |
| 738 | int limit = flag_alternateform ? va_arg(ap, int) : -1; |
| 739 | Blob *pBlob = va_arg(ap, Blob*); |
| 740 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -728,12 +728,12 @@ | |
| 728 | }else if( xtype==etDYNSTRING ){ |
| 729 | zExtra = bufpt; |
| 730 | }else if( xtype==etSTRINGID ){ |
| 731 | precision = hash_digits(flag_altform2); |
| 732 | } |
| 733 | if( limit<0 || (precision>=0 && precision<limit) ) limit = precision; |
| 734 | length = StrNLen32(bufpt, limit); |
| 735 | break; |
| 736 | } |
| 737 | case etBLOB: { |
| 738 | int limit = flag_alternateform ? va_arg(ap, int) : -1; |
| 739 | Blob *pBlob = va_arg(ap, Blob*); |
| 740 |