mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-22 06:11:31 +03:00
vere: fix u3v_lily bounds checking
Before this, u3v_lily would erroneously accept atoms bigger than 64 bits that, when truncated to 64 bits, were 31-bit numbers. Decided to drop _cv_mole altogether. Another option would be to write a u3r_chub_fit, write _cv_mole in terms of that, and check width in u3v_lily as it currently does. I tried to add a test case, but it seems that tests don't have access to an ivory pill for +scot / +slaw. This would be the test case, more or less: { c3_l lit_l; c3_w big_w[] = {0, 0, 1}; u3_atom big = u3i_words(3, big_w); u3_noun cod = u3dc("scot", c3__ux, big); if ( c3y == u3v_lily(c3__ux, cod, &lit_l) ) { printf("fail\n"); } } (The refcounting was also messed up, possibly from my refactor to use +slaw instead of +slay, but this seems to have been unrelated.)
This commit is contained in:
parent
d64674c0e8
commit
2526c4b59d
@ -193,47 +193,26 @@ u3v_peek(u3_noun sam)
|
||||
return u3n_slam_on(fun, sam);
|
||||
}
|
||||
|
||||
/* _cv_mole(): parse simple atomic mole.
|
||||
*/
|
||||
static c3_o
|
||||
_cv_mole(u3_noun fot,
|
||||
u3_noun san,
|
||||
c3_d* ato_d)
|
||||
{
|
||||
u3_noun uco = u3dc("slaw", fot, san);
|
||||
u3_noun p_uco, q_uco;
|
||||
|
||||
if ( (c3n == u3r_cell(uco, &p_uco, &q_uco)) ||
|
||||
(u3_nul != p_uco) )
|
||||
{
|
||||
u3l_log("strange mole %s\n", u3r_string(san));
|
||||
|
||||
u3z(fot); u3z(uco); return c3n;
|
||||
}
|
||||
else {
|
||||
*ato_d = u3r_chub(0, q_uco);
|
||||
|
||||
u3z(fot); u3z(uco); return c3y;
|
||||
}
|
||||
}
|
||||
|
||||
/* u3v_lily(): parse little atom.
|
||||
*/
|
||||
c3_o
|
||||
u3v_lily(u3_noun fot, u3_noun txt, c3_l* tid_l)
|
||||
{
|
||||
c3_d ato_d;
|
||||
c3_w wad_w;
|
||||
u3_noun uco = u3dc("slaw", fot, u3k(txt));
|
||||
u3_noun p_uco, q_uco;
|
||||
|
||||
if ( c3n == _cv_mole(fot, txt, &ato_d) ) {
|
||||
return c3n;
|
||||
} else {
|
||||
if ( ato_d >= 0x80000000ULL ) {
|
||||
return c3n;
|
||||
} else {
|
||||
*tid_l = (c3_l) ato_d;
|
||||
|
||||
return c3y;
|
||||
}
|
||||
if ( (c3n == u3r_cell(uco, &p_uco, &q_uco)) ||
|
||||
(u3_nul != p_uco) ||
|
||||
!u3r_word_fit(&wad_w, q_uco) ||
|
||||
(wad_w & 0x80000000) )
|
||||
{
|
||||
u3l_log("strange lily %s\n", u3r_string(txt));
|
||||
u3z(txt); u3z(uco); return c3n;
|
||||
}
|
||||
else {
|
||||
*tid_l = (c3_l)wad_w;
|
||||
u3z(txt); u3z(uco); return c3y;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user