Fossil

Check-in [8ccedde4c6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a bug in comment_print() discovered by the fuzzer enhancement of the previous check-in. This bug has existed for a long time and is not the result of recent changes.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8ccedde4c6b4bdd55cd2516ebb8c7fc9b7539545db69cd500dcee08b23042086
User & Date: drh 2025-02-27 12:22:48.957
Context
2025-02-27
12:33
Update the fuzz-testing documentation. check-in: 16d98b94bb user: drh tags: trunk
12:22
Fix a bug in comment_print() discovered by the fuzzer enhancement of the previous check-in. This bug has existed for a long time and is not the result of recent changes. check-in: 8ccedde4c6 user: drh tags: trunk
01:50
Extend the fuzzer to have the ability to run comment_print(). check-in: 8639f9b2d5 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/comformat.c.
218
219
220
221
222
223
224

225
226
227
228
229
230
231
  const char *zLine, /* [in] The comment line being printed. */
  int index,         /* [in] The current character index being handled. */
  int maxChars,      /* [in] Optimization hint to abort before space found. */
  int *sumWidth      /* [out] Summated width of all characters to next space. */
){
  int cchUTF8, utf32, wcwidth = 0;
  int nextIndex = index;

  for(;;){
    char_info_utf8(&zLine[nextIndex],&cchUTF8,&utf32);
    nextIndex += cchUTF8;
    wcwidth += cli_wcwidth(utf32);
    if( zLine[nextIndex]==0 || fossil_isspace(zLine[nextIndex]) ||
        wcwidth>maxChars ){
      *sumWidth = wcwidth;







>







218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
  const char *zLine, /* [in] The comment line being printed. */
  int index,         /* [in] The current character index being handled. */
  int maxChars,      /* [in] Optimization hint to abort before space found. */
  int *sumWidth      /* [out] Summated width of all characters to next space. */
){
  int cchUTF8, utf32, wcwidth = 0;
  int nextIndex = index;
  if( zLine[index]==0 ) return index;
  for(;;){
    char_info_utf8(&zLine[nextIndex],&cchUTF8,&utf32);
    nextIndex += cchUTF8;
    wcwidth += cli_wcwidth(utf32);
    if( zLine[nextIndex]==0 || fossil_isspace(zLine[nextIndex]) ||
        wcwidth>maxChars ){
      *sumWidth = wcwidth;