You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An assignment to a global variable that is used in the bounds of another global variable does not produce a compile error. This can lead to a buffer overflow when the second global variable is later accessed. In the analogous situation with a local variable, a compile error is correctly reported. Example:
#pragma CHECKED_SCOPE on
#include<stdlib.h>size_tglobal_len=5;
_Array_ptr<char>global_ptr : count(global_len);
intmain(void) {
size_tlocal_len=5;
_Array_ptr<char>local_ptr : count(local_len) =0;
local_ptr=malloc<char>(local_len);
//local_len = 100000000; // Compile error, as expectedlocal_len=100000000, local_ptr=malloc<char>(local_len); // OKglobal_ptr=malloc<char>(global_len);
global_len=100000000; // Should be a compile errorfor (size_ti=0; i<global_len; i++)
global_ptr[i]++; // SIGSEGVreturn0;
}
The text was updated successfully, but these errors were encountered:
This checking isn't implemented in the compiler. The spec requires this checking be implemented. As you point out, all the machinery is there. We just need to include global variables in the list of variables being checked.
An assignment to a global variable that is used in the bounds of another global variable does not produce a compile error. This can lead to a buffer overflow when the second global variable is later accessed. In the analogous situation with a local variable, a compile error is correctly reported. Example:
The text was updated successfully, but these errors were encountered: