Skip to content

Undefined Behavior (caught by ASAN) #26

@DUOLabs333

Description

@DUOLabs333

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);
	}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions