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

Undefined Behavior (caught by ASAN) #26

Open
DUOLabs333 opened this issue Sep 25, 2024 · 0 comments
Open

Undefined Behavior (caught by ASAN) #26

DUOLabs333 opened this issue Sep 25, 2024 · 0 comments

Comments

@DUOLabs333
Copy link

I've been using this library for a while in a project of mine, and it's been working perfectly for me. However, recently, I pushed an update that broke in very specific scenarios. After debugging for ~3 hours, I was able to trace it to this library: as it turns out, tb64enc reads in past inlen, and writes to out past tb64enclen(inlen). An MRE is given below (compile this and the library with -fsanitize=address):

#include <turbob64.h>
#include <string.h>
#include <stdio.h>
int main(){

	auto buf = new char[128]; //For there to be no error, this needs to be at least 132

	auto data = new char[94]; //For there to be no error, this needs to be at least 97

	memset(data, 0, 94);

	for(int i=0; i< 128; i++){
			printf("Length: %zu\n", tb64enclen(94));
			tb64enc((unsigned char*)data, 94, (unsigned char*)buf);
	}

}
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

No branches or pull requests

1 participant