strcpy() -> strncpy() changes from Bruce Hill
Also added some additional static assertions for string field sizes.
This commit is contained in:
@@ -93,6 +93,7 @@ static long readValue(stringinRecord *);
|
||||
static long init_record(stringinRecord *prec, int pass)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(prec->oval)==sizeof(prec->val));
|
||||
STATIC_ASSERT(sizeof(prec->sval)==sizeof(prec->val));
|
||||
struct stringindset *pdset;
|
||||
long status;
|
||||
|
||||
@@ -119,7 +120,7 @@ static long init_record(stringinRecord *prec, int pass)
|
||||
if( pdset->init_record ) {
|
||||
if((status=(*pdset->init_record)(prec))) return(status);
|
||||
}
|
||||
strcpy(prec->oval,prec->val);
|
||||
strncpy(prec->oval, prec->val, sizeof(prec->val));
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -193,7 +194,7 @@ static long readValue(stringinRecord *prec)
|
||||
status=dbGetLink(&(prec->siol),DBR_STRING,
|
||||
prec->sval,0,0);
|
||||
if (status==0) {
|
||||
strcpy(prec->val,prec->sval);
|
||||
strncpy(prec->val, prec->sval, sizeof(prec->val));
|
||||
prec->udf=FALSE;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -95,6 +95,7 @@ static long writeValue(stringoutRecord *);
|
||||
static long init_record(stringoutRecord *prec, int pass)
|
||||
{
|
||||
STATIC_ASSERT(sizeof(prec->oval)==sizeof(prec->val));
|
||||
STATIC_ASSERT(sizeof(prec->ivov)==sizeof(prec->val));
|
||||
struct stringoutdset *pdset;
|
||||
long status=0;
|
||||
|
||||
@@ -121,7 +122,7 @@ static long init_record(stringoutRecord *prec, int pass)
|
||||
if( pdset->init_record ) {
|
||||
if((status=(*pdset->init_record)(prec))) return(status);
|
||||
}
|
||||
strcpy(prec->oval,prec->val);
|
||||
strncpy(prec->oval, prec->val, sizeof(prec->val));
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -159,7 +160,7 @@ static long process(stringoutRecord *prec)
|
||||
break;
|
||||
case (menuIvoaSet_output_to_IVOV) :
|
||||
if(prec->pact == FALSE){
|
||||
strcpy(prec->val,prec->ivov);
|
||||
strncpy(prec->val, prec->ivov, sizeof(prec->val));
|
||||
}
|
||||
status=writeValue(prec); /* write the new value */
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user