Browse Source

fix dangerous things, potential bugs, at least for big endian machines

pre-master-46
rlar 16 years ago
parent
commit
62afa50a1c
  1. 15
      ChangeLog
  2. 3
      src/frontend/inp.c
  3. 8
      src/frontend/spiceif.c
  4. 2
      src/frontend/variable.c

15
ChangeLog

@ -1,3 +1,18 @@
2010-07-24 Robert Larice
fix dangerous things, potential bugs, at least for big endian machines
* src/frontend/inp.c ,
a bool (unsigned char) and an int have been mixed,
and the address of the thing was taken.
should fail on a big endian machine
* src/frontend/spiceif.c ,
the value of an union, made of a bool (unsigned char), an int, etc,
is silently cast into an int.
This can introduce stack noise, in the CP_BOOL case
* src/frontend/variable.c :
a `variable' is created with type CP_NUM,
but only bool was initialized.
This can introduce stack noise.
2010-07-24 Robert Larice 2010-07-24 Robert Larice
* src/include/onedev.h , * src/include/onedev.h ,
* src/include/twodev.h : * src/include/twodev.h :

3
src/frontend/inp.c

@ -697,7 +697,6 @@ inp_dodeck(
wordlist *wl; wordlist *wl;
bool noparse, ii; bool noparse, ii;
int print_listing; int print_listing;
static int one;
/* First throw away any old error messages there might be and fix /* First throw away any old error messages there might be and fix
the case of the lines. */ the case of the lines. */
@ -882,7 +881,7 @@ inp_dodeck(
} }
*/ */
for (eev = ct->ci_vars; eev; eev = eev->va_next) { for (eev = ct->ci_vars; eev; eev = eev->va_next) {
one = 1;
bool one = TRUE; /* FIXME, actually eev->va_bool should be TRUE anyway */
switch (eev->va_type) { switch (eev->va_type) {
case CP_BOOL: case CP_BOOL:
if_option(ct->ci_ckt, eev->va_name, if_option(ct->ci_ckt, eev->va_name,

8
src/frontend/spiceif.c

@ -472,8 +472,12 @@ if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value)
goto badtype; goto badtype;
break; break;
case IF_FLAG: case IF_FLAG:
/* Do nothing. */
pval.iValue = *((int *) value);
if (type == CP_BOOL)
pval.iValue = *((bool *) value) ? 1 : 0;
else if (type == CP_NUM) /* FIXME, shall we allow this ? */
pval.iValue = *((int *) value);
else
goto badtype;
break; break;
default: default:
fprintf(cp_err, fprintf(cp_err,

2
src/frontend/variable.c

@ -449,7 +449,7 @@ cp_remvar(char *varname)
ZERO(v, struct variable); ZERO(v, struct variable);
v->va_name = copy(varname); v->va_name = copy(varname);
v->va_type = CP_NUM; v->va_type = CP_NUM;
v->va_bool = 0;
v->va_num = 0;
found = FALSE; found = FALSE;
} }

Loading…
Cancel
Save