Should possibly append a single zero byte and pass max + 1 to the function above