Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in new function strrep in tmbstr.c #1001

Open
sonyps5201314 opened this issue Sep 28, 2021 · 0 comments · May be fixed by #1008
Open

bug in new function strrep in tmbstr.c #1001

sonyps5201314 opened this issue Sep 28, 2021 · 0 comments · May be fixed by #1008
Milestone

Comments

@sonyps5201314
Copy link

sonyps5201314 commented Sep 28, 2021

 src/tmbstr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tmbstr.c b/src/tmbstr.c
index e352698..447c6dd 100644
--- a/src/tmbstr.c
+++ b/src/tmbstr.c
@@ -255,7 +255,7 @@ void TY_(strrep)(tmbstr buffer, ctmbstr str, ctmbstr rep)
         if(p)
         {
             char buf[1024];
-            memset(buf,'\0',strlen(buf));
+            memset(buf,'\0',sizeof(buf));
 
             if(buffer == p)
             {

if use vc to build the solution with debug config, and call tidyRunDiagnostics with the html in the attachment zip file, will trigger the problem.

@sonyps5201314 sonyps5201314 changed the title bug in new fucntion strrep in tmbstr.c bug in new function strrep in tmbstr.c Sep 28, 2021
@balthisar balthisar added this to the 5.9 milestone Oct 12, 2021
alpire added a commit to alpire/tidy-html5 that referenced this issue Oct 27, 2021
`strlen(buf)` is not guaranteed to return the size of the buffer, as it
might contain some null bytes in the middle.

Fixes htacg#1001
@alpire alpire linked a pull request Oct 27, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants