From 68afbed2ce09cf3a422179c7ae07d80aa59bb1cf Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 20 Jun 2014 13:15:26 +1000 Subject: [PATCH] Prevent SEGV in ansto_sctdriveadapter on node not found and add names to messages --- site_ansto/ansto_sctdriveadapter.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/site_ansto/ansto_sctdriveadapter.c b/site_ansto/ansto_sctdriveadapter.c index aa55c8ab..af940659 100644 --- a/site_ansto/ansto_sctdriveadapter.c +++ b/site_ansto/ansto_sctdriveadapter.c @@ -310,7 +310,7 @@ int ANSTO_SctMakeDriveAdapter(SConnection *pCon, SicsInterp *pSics, void *object pSICSOBJ obj = NULL; hdbCallback *cb; - if(argc < 4){ + if(argc < 5){ SCWrite(pCon,"ERROR: not enough arguments for ANSTO_SctMakeDriveAdapter", eError); return 0; } @@ -324,19 +324,21 @@ int ANSTO_SctMakeDriveAdapter(SConnection *pCon, SicsInterp *pSics, void *object pNew->write_node = FindHdbNode(NULL, argv[2], pCon); if (pNew->write_node == NULL) - SCWrite(pCon, "ERROR: write-node not found", eError); - if (pNew->write_node->value.dataType != HIPFLOAT && pNew->write_node->value.dataType != HIPINT) { - SCWrite(pCon, "ERROR: write-node not INT or FLOAT", eError); + SCPrintf(pCon, eError, "ERROR: write-node %s not found", argv[2]); + else if (pNew->write_node->value.dataType != HIPFLOAT && pNew->write_node->value.dataType != HIPINT) { + SCPrintf(pCon, eError, "ERROR: write-node %s not INT or FLOAT", argv[2]); pNew->write_node = NULL; } pNew->read_node = FindHdbNode(NULL, argv[3], pCon); - if (pNew->read_node->value.dataType != HIPFLOAT && pNew->read_node->value.dataType != HIPINT) { - SCWrite(pCon, "ERROR: read-node not INT or FLOAT", eError); + if (pNew->read_node == NULL) + SCPrintf(pCon, eError, "ERROR: read-node %s not found", argv[3]); + else if (pNew->read_node->value.dataType != HIPFLOAT && pNew->read_node->value.dataType != HIPINT) { + SCPrintf(pCon, eError, "ERROR: read-node %s not INT or FLOAT", argv[3]); pNew->write_node = NULL; } obj = FindCommandData(pSics,argv[4], "SctController"); if (obj == NULL) - SCWrite(pCon, "ERROR: controller not found", eError); + SCPrintf(pCon, eError, "ERROR: controller %s not found", argv[4]); if (pNew->write_node == NULL || pNew->read_node == NULL || obj == NULL) { SctDriveKill(pNew); return 0;