Skip to content

Commit

Permalink
dynamic: reduced dst_len for enc_lc/enc_uc to avoid overflow from #5029
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyCherepanov authored and solardiz committed Feb 19, 2022
1 parent abab083 commit e3b3206
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dynamic_fmt.c
Expand Up @@ -8429,13 +8429,15 @@ static char *HandleCase(char *cp, int caseType)
case 1:
return cp;
case 2:
enc_uc(dest, sizeof(dest), (unsigned char*)cp, strlen(cp));
/* -1 is a temporary workaround for #5029 */
enc_uc(dest, sizeof(dest) - 1, (unsigned char*)cp, strlen(cp));
if (!strcmp((char*)dest, cp))
return cp;
break;
case 3:
case 4:
enc_lc(dest, sizeof(dest), (unsigned char*)cp, strlen(cp));
/* -1 is a temporary workaround for #5029 */
enc_lc(dest, sizeof(dest) - 1, (unsigned char*)cp, strlen(cp));
if (caseType == 4)
dest[0] = low2up_ansi(dest[0]);
if (!strcmp((char*)dest, cp))
Expand Down

0 comments on commit e3b3206

Please sign in to comment.