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.

dmestas 2026-11-14 02:34 UTC small-fixes-2
Commit da1ce17a27a73640b0af17a74fc3d8e519670b7a2d84a48ca6547e90a3d8482b
1 file changed +1 -1
+1 -1
--- src/printf.c
+++ src/printf.c
@@ -728,12 +728,12 @@
728728
}else if( xtype==etDYNSTRING ){
729729
zExtra = bufpt;
730730
}else if( xtype==etSTRINGID ){
731731
precision = hash_digits(flag_altform2);
732732
}
733
+ if( limit<0 || (precision>=0 && precision<limit) ) limit = precision;
733734
length = StrNLen32(bufpt, limit);
734
- if( precision>=0 && precision<length ) length = precision;
735735
break;
736736
}
737737
case etBLOB: {
738738
int limit = flag_alternateform ? va_arg(ap, int) : -1;
739739
Blob *pBlob = va_arg(ap, Blob*);
740740
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button