mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
tip: Fix pointer-vs-integer confusion
Currently IREMOTE assumes that every value is (initially) a pointer to a long. This is true for NUMBERs, but false for STRINGs, which are instead pointers to pointers, though on ILP32 and LP64 systems these happen to have the same representation, but this is still a strict aliasing violation, and of course breaks on systems where the representations are not the same, such as CHERI. We do not currently have any BOOLs (short, curiously) or CHARs used with IREMOTE, though the code should not be relying on that. This removes the unused setaddress macro, and the now-unused address macro due to the above issue. Reviewed by: imp, kib Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D30697
This commit is contained in:
parent
de295884c4
commit
6d2648bcab
2 changed files with 16 additions and 4 deletions
|
|
@ -158,12 +158,10 @@ typedef
|
|||
#define number(v) ((long)(intptr_t)(v))
|
||||
#define boolean(v) ((short)(intptr_t)(v))
|
||||
#define character(v) ((char)(intptr_t)(v))
|
||||
#define address(v) ((long *)(v))
|
||||
|
||||
#define setnumber(v,n) do { (v) = (char *)(intptr_t)(n); } while (0)
|
||||
#define setboolean(v,n) do { (v) = (char *)(intptr_t)(n); } while (0)
|
||||
#define setcharacter(v,n) do { (v) = (char *)(intptr_t)(n); } while (0)
|
||||
#define setaddress(v,n) do { (v) = (char *)(n); } while (0)
|
||||
|
||||
/*
|
||||
* Escape command table definitions --
|
||||
|
|
|
|||
|
|
@ -69,8 +69,22 @@ vinit(void)
|
|||
if (p->v_type&ENVIRON)
|
||||
if ((cp = getenv(p->v_name)))
|
||||
p->v_value = cp;
|
||||
if (p->v_type&IREMOTE)
|
||||
setnumber(p->v_value, *address(p->v_value));
|
||||
if (p->v_type&IREMOTE) {
|
||||
switch (p->v_type&TMASK) {
|
||||
case STRING:
|
||||
p->v_value = *(char **)p->v_value;
|
||||
break;
|
||||
case NUMBER:
|
||||
setnumber(p->v_value, *(long *)p->v_value);
|
||||
break;
|
||||
case BOOL:
|
||||
setboolean(p->v_value, *(short *)p->v_value);
|
||||
break;
|
||||
case CHAR:
|
||||
setcharacter(p->v_value, *(char *)p->v_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Read the .tiprc file in the HOME directory
|
||||
|
|
|
|||
Loading…
Reference in a new issue