ublk-org / ublksrv

ublk: userspace block device driver
MIT License
149 stars 53 forks source link

Fix gcc -O3 buffer size warning #40

Closed snarkmaster closed 1 year ago

snarkmaster commented 1 year ago

There is no actual buffer overrun here, since PATH_MAX includes a null character (per @ming1 below). However, gcc -O3 issues a warning when "size of buffer" == "size of strncmp" which becomes fatal since build_with_liburing_src specifies -Wall.

So, let just fix this to be "pedantically correct", and not simply "actually correct" :)

snarkmaster commented 1 year ago

Ok, here's a change to update the strncpy invocation instead. The reason that this change is needed is that gcc -O3 will issue otherwise issue a (fatal) warning because with the current code, exe might end up not being null-terminated:

If there is no null byte among the first n bytes of src, the string placed in dest will not be null-terminated.

Of course, it doesn't know that PATH_MAX already accounts for null.

ming1 commented 1 year ago

merged