- Changed strncpy to strlcpy, strncat to strlcat

- Added strlcpy and strlcat to SICS
- Added a driver for the POLDI power supplies
This commit is contained in:
koennecke
2010-04-13 15:08:40 +00:00
parent 9e4eabeed1
commit dec6b04fa6
49 changed files with 679 additions and 653 deletions

View File

@@ -108,12 +108,12 @@ static int sinqHttpCheckResponse(pSinqHttp self)
}
if (strstr(pPtr, "ERROR") != NULL) {
memset(self->hmError, 0, 512 * sizeof(char));
strncpy(self->hmError, pPtr, len);
strlcpy(self->hmError, pPtr, len);
self->errorCode = HTTPERROR;
return 0;
} else if (strstr(pPtr, "Authentication Error") != NULL) {
memset(self->hmError, 0, 512 * sizeof(char));
strncpy(self->hmError, pPtr, len);
strlcpy(self->hmError, pPtr, len);
self->errorCode = BADAUTH;
return 0;
}
@@ -141,7 +141,7 @@ static int sinqHttpGet(pSinqHttp self, char *request)
httpStatus = ghttp_process(self->syncRequest);
}
if (httpStatus != ghttp_done) {
strncpy(self->hmError, "Reconnect", 511);
strlcpy(self->hmError, "Reconnect", 511);
self->errorCode = SERVERERROR;
return 0;
} else {
@@ -362,7 +362,7 @@ static int readStatus(pHistDriver pDriv)
pPtr = ghttp_get_body(self->syncRequest);
if (pPtr == NULL) {
strncpy(self->hmError, "No body in status response", 131);
strlcpy(self->hmError, "No body in status response", 131);
self->errorCode = NOBODY;
return 0;
}
@@ -415,7 +415,7 @@ static int SinqHttpStatus(pHistDriver self, SConnection * pCon)
ghttp_prepare(pPriv->syncRequest);
httpStatus = ghttp_process(pPriv->syncRequest);
if (httpStatus != ghttp_done) {
strncpy(pPriv->hmError, "Reconnect", 511);
strlcpy(pPriv->hmError, "Reconnect", 511);
pPriv->errorCode = SERVERERROR;
pPriv->asyncRunning = 0;
return HWFault;
@@ -440,7 +440,7 @@ static int SinqHttpStatus(pHistDriver self, SConnection * pCon)
if (StringDictGet(self->pOption, "daq", daqStatus, 20) != 1) {
pPriv->errorCode = BADSTATUS;
strncpy(pPriv->hmError, "ERROR: status does not contain DAQ field",
strlcpy(pPriv->hmError, "ERROR: status does not contain DAQ field",
511);
return HWFault;
}
@@ -468,7 +468,7 @@ static int SinqHttpError(pHistDriver self, int *code,
pPriv = (pSinqHttp) self->pPriv;
assert(pPriv != NULL);
strncpy(error, pPriv->hmError, errLen);
strlcpy(error, pPriv->hmError, errLen);
*code = pPriv->errorCode;
return 1;
}
@@ -561,7 +561,7 @@ static int SinqHttpGetHistogram(pHistDriver self, SConnection * pCon,
len = ghttp_get_body_len(pPriv->syncRequest);
if (len < (end - start) * sizeof(int)) {
pPriv->errorCode = BODYSHORT;
strncpy(pPriv->hmError, "Not enough data received from HM", 511);
strlcpy(pPriv->hmError, "Not enough data received from HM", 511);
return HWFault;
}
hmdata = (HistInt *) ghttp_get_body(pPriv->syncRequest);
@@ -600,14 +600,14 @@ static HistInt *SinqHttpSubSample(pHistDriver self, SConnection * pCon,
len = ghttp_get_body_len(pPriv->syncRequest);
if (len <= 0) {
strncpy(pPriv->hmError, "ERROR: no data returned from subsampling",
strlcpy(pPriv->hmError, "ERROR: no data returned from subsampling",
511);
pPriv->errorCode = BADSUBSAMPLE;
return NULL;
}
resultdata = malloc(len + 4);
if (resultdata == NULL) {
strncpy(pPriv->hmError,
strlcpy(pPriv->hmError,
"ERROR: failed to allocate buffer for subsampling results",
511);
pPriv->errorCode = HMNOMEMORY;
@@ -632,7 +632,7 @@ static int SinqHttpSetHistogram(pHistDriver self, SConnection * pCon,
assert(pPriv != NULL);
pPriv->errorCode = NOTIMPLEMENTED;
strncpy(pPriv->hmError, "Not implemented", 511);
strlcpy(pPriv->hmError, "Not implemented", 511);
return HWFault;
}