Skip to content

Commit 54b3fe0

Browse files
committed
fix strncpy errors and allow char waveforms
1 parent d80cc65 commit 54b3fe0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

luaApp/src/rec/luascriptRecord.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void logError(luascriptRecord* record)
132132

133133
errlogPrintf("Calling %s resulted in error: %s\n", record->call, err.c_str());
134134

135-
strcpy(record->err, err.c_str());
135+
memcpy(record->err, err.c_str(), len(record->err));
136136
db_post_events(record, &record->err, DBE_VALUE);
137137
}
138138

@@ -429,7 +429,7 @@ static long loadStrings(luascriptRecord* record)
429429

430430
for (unsigned index = 0; index < STR_ARGS; index += 1)
431431
{
432-
strncpy(*prev_str, strvalue, STRING_SIZE);
432+
memcpy(*prev_str, strvalue, STRING_SIZE);
433433

434434
short field_type = 0;
435435
long elements = 1;
@@ -440,10 +440,6 @@ static long loadStrings(luascriptRecord* record)
440440

441441
switch(field_type)
442442
{
443-
case DBF_CHAR:
444-
elements = std::min(elements, (long) STRING_SIZE - 1);
445-
//Intentional fall-through
446-
447443
case DBF_ENUM:
448444
case DBF_STRING:
449445
{
@@ -467,13 +463,17 @@ static long loadStrings(luascriptRecord* record)
467463
}
468464

469465
if (status) { break; }
470-
471-
strncpy(strvalue, tempstr, STRING_SIZE);
472-
466+
467+
memcpy(strvalue, tempstr, STRING_SIZE);
468+
473469
lua_pushstring(state, tempstr);
474470

475471
break;
476472
}
473+
474+
case DBF_CHAR:
475+
status = createTable<epicsInt8>(state, field, field_type, &elements, true);
476+
break;
477477

478478
case DBF_UCHAR:
479479
status = createTable<epicsUInt8>(state, field, field_type, &elements, true);

0 commit comments

Comments
 (0)