vmonaco / kloak

Keystroke-level online anonymization kernel: obfuscates typing behavior at the device level.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

replace strncpy with safer function for better security

adrelanos opened this issue · comments

After #65 was either merged or rejected... (Otherwise seems suggesting code changes on top of yet to be reviwed code changes.)

chatgpt suggested to replace strncpy with strlcpy.

#include <bsd/string.h> // Include this header for strlcpy

If that makes sense, I am happy to work on a PR soon after #65 has been decided.


In case you're wondering why I am doing these maybe nitpick (?), perfectionist (?) changes... I hope that with 100% memory allocation and string parsing correctness, a few rare corner cases bugs might be fixed:

Might also fix:

Another option that might provide even better protection is to change main to use c++ instead of c. I ran a quick test, and it it only requires changing 2 lines in the makefile and 3 lines in main. Once it's changed to c++, kloak can use c++'s string objects in place of c strings which automatically track their length and automatically check the length of the source and destination string