...
Code Block | ||||
---|---|---|---|---|
| ||||
int (*log_fn)(const char *, ...) = EncodePointer(printf); /* ... */ DecodePointer(log_fn)("foo"); |
Compliant Solution (C1X)
Two similar functions are under consideration for the C1X major revision to the C Standard.
C1X defines encode_pointer()
to have the following behavior:
The encode_pointer function shall perform a transformation on the
pf
argument, such that thedecode_pointer
function shall reverse that transformation. Thus, for any pointer to functionpfun
,
Code Block decode_pointer(encode_pointer( (void(*)()) pfun )
when converted to the type of
pfun
, shall equalpfun
.
Code Block | ||||
---|---|---|---|---|
| ||||
int (*log_fn)(const char *, ...) = encode_pointer(printf);
/* ... */
decode_pointer(log_fn)("foo");
|
Risk Assessment
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
MSC16-C | high | unlikely | low | P9 | L2 |
...