__fortified_attr_access seems to be defined incorrectly for _FORTIFY_SOURCE==3.
The documentation for the size-index of access attribute (https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-access-function-attribute) has the following:
```
When no size-index argument is specified, the pointer argument must be either null or point to a space that is suitably aligned and large for __at least one object__ of the referenced type (this implies that a past-the-end pointer is not a valid argument).
```
Notice the __at least__ part here. That means the definition of __fortified_attr_access is wrong when _FORTIFY_SOURCE==3, when passing around 0 size structs.
An example is:
```
#include <stdio.h>
#include <unistd.h>
int main(void) {
struct test_st {};
int fd = 0;
int count = 0;
__fortified_ attr_access seems to be defined incorrectly for _FORTIFY_SOURCE==3. /gcc.gnu. org/onlinedocs/ gcc/Common- Function- Attributes. html#index- access- function- attribute) has the following:
The documentation for the size-index of access attribute (https:/
```
When no size-index argument is specified, the pointer argument must be either null or point to a space that is suitably aligned and large for __at least one object__ of the referenced type (this implies that a past-the-end pointer is not a valid argument).
```
Notice the __at least__ part here. That means the definition of __fortified_ attr_access is wrong when _FORTIFY_SOURCE==3, when passing around 0 size structs.
An example is:
```
#include <stdio.h>
#include <unistd.h>
int main(void) {
struct test_st {};
int fd = 0;
int count = 0;
struct test_st test_info[16];
count = read(fd, test_info, sizeof(test_info));
return(0);
}
```
With _FORTIFY_SOURCE==3 we get:
__attribute__ ((__access__ (__write_only__, 2)))
Which means the size has to be at least 1 but test_info has size of 0 and we are passing a size of 0 to read even.
This is moved from GCC bug: https:/ /gcc.gnu. org/bugzilla/ show_bug. cgi?id= 113922 .