Changeset View
Changeset View
Standalone View
Standalone View
cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
Show First 20 Lines • Show All 1,199 Lines • ▼ Show 20 Lines | case CTF_K_CONST: | ||||
tdp->t_tdesc = tdarr[ctt->ctt_type]; | tdp->t_tdesc = tdarr[ctt->ctt_type]; | ||||
break; | break; | ||||
case CTF_K_FUNCTION: | case CTF_K_FUNCTION: | ||||
tdp->t_type = FUNCTION; | tdp->t_type = FUNCTION; | ||||
tdp->t_fndef = xcalloc(sizeof (fndef_t)); | tdp->t_fndef = xcalloc(sizeof (fndef_t)); | ||||
tdp->t_fndef->fn_ret = tdarr[ctt->ctt_type]; | tdp->t_fndef->fn_ret = tdarr[ctt->ctt_type]; | ||||
v = (void *) (dptr + (sizeof (ushort_t) * (vlen - 1))); | v = (void *) (dptr + (ptrdiff_t)(sizeof (ushort_t) * (vlen - 1))); | ||||
jrtc27: What's the reasoning behind this one? You should have `size_t * int` which will give either… | |||||
arichardsonAuthorUnsubmitted Done Inline ActionsI can't remember what the error was, I think it was that vlen can be zero and UBSan complains that adding a large unsigned number to dptr overflows it. arichardson: I can't remember what the error was, I think it was that vlen can be zero and UBSan complains… | |||||
jrtc27Unsubmitted Not Done Inline ActionsThen the if below should be: if (vlen > 0 && ((u_short *)dptr)[vlen - 1] == 0) and this line can go? jrtc27: Then the `if` below should be:
```
if (vlen > 0 && ((u_short *)dptr)[vlen - 1] == 0)
```
and… | |||||
if (vlen > 0 && *(ushort_t *)v == 0) | if (vlen > 0 && *(ushort_t *)v == 0) | ||||
tdp->t_fndef->fn_vargs = 1; | tdp->t_fndef->fn_vargs = 1; | ||||
tdp->t_fndef->fn_nargs = vlen - tdp->t_fndef->fn_vargs; | tdp->t_fndef->fn_nargs = vlen - tdp->t_fndef->fn_vargs; | ||||
tdp->t_fndef->fn_args = xcalloc(sizeof (tdesc_t) * | tdp->t_fndef->fn_args = xcalloc(sizeof (tdesc_t) * | ||||
vlen - tdp->t_fndef->fn_vargs); | vlen - tdp->t_fndef->fn_vargs); | ||||
for (i = 0; i < vlen; i++) { | for (i = 0; i < vlen; i++) { | ||||
▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines |
What's the reasoning behind this one? You should have size_t * int which will give either int or size_t depending on 32-bit vs 64-bit, I believe, both of which should then work fine as an offset. But if there's something weird going on with that would it not be best to make vlen a size_t instead?