summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 5d37e14..4a3a424 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -394,26 +394,26 @@ int file_hex_ascii(FILE *filePtr, unsigned int buffer[],
addressPerLine = 0x08;
loByte = (unsigned char) buffer[address];
hiByte = (unsigned char) (buffer[address] >> 8);
- sprintf(lineBuf, "%02x %02x ", hiByte, loByte);
- strcat(dataStr, lineBuf);
+ snprintf(lineBuf, sizeof(lineBuf), "%02x %02x ", hiByte, loByte);
+ strlcat(dataStr, lineBuf, sizeof(dataStr));
if ((hiByte > 31) && (hiByte < 127))
- sprintf(lineBuf, "%c", hiByte);
+ snprintf(lineBuf, sizeof(lineBuf), "%c", hiByte);
else
- sprintf(lineBuf, ".");
- strcat(asciiStr, lineBuf);
+ snprintf(lineBuf, sizeof(lineBuf), ".");
+ strlcat(asciiStr, lineBuf, sizeof(asciiStr));
if ((loByte > 31) && (loByte < 127))
- sprintf(lineBuf, "%c", loByte);
+ snprintf(lineBuf, sizeof(lineBuf), "%c", loByte);
else
- sprintf(lineBuf, ".");
- strcat(asciiStr, lineBuf);
+ snprintf(lineBuf, sizeof(lineBuf), ".");
+ strlcat(asciiStr, lineBuf, sizeof(asciiStr));
} else {
- sprintf(lineBuf, "%02x ", buffer[address]);
- strcat(dataStr, lineBuf);
+ snprintf(lineBuf, sizeof(lineBuf), "%02x ", buffer[address]);
+ strlcat(dataStr, lineBuf, sizeof(dataStr));
if ((buffer[address] > 31) && (buffer[address] < 127))
- sprintf(lineBuf, "%c", buffer[address]);
+ snprintf(lineBuf, sizeof(lineBuf), "%c", buffer[address]);
else
- sprintf(lineBuf, ".");
- strcat(asciiStr, lineBuf);
+ snprintf(lineBuf, sizeof(lineBuf), ".");
+ strlcat(asciiStr, lineBuf, sizeof(asciiStr));
}
}
if ((fprintf(filePtr, "%06lx %s %s\n",
@@ -509,26 +509,26 @@ void printBuffer(unsigned int buffer[], long bufLimit, int twoByteFlag) {
addressPerLine = 0x08;
loByte = (unsigned char) buffer[address];
hiByte = (unsigned char) (buffer[address] >> 8);
- sprintf(lineBuf, "%02x %02x ", hiByte, loByte);
- strcat(dataStr, lineBuf);
+ snprintf(lineBuf, sizeof(lineBuf), "%02x %02x ", hiByte, loByte);
+ strlcat(dataStr, lineBuf, sizeof(dataStr));
if ((hiByte > 31) && (hiByte < 127))
- sprintf(lineBuf, "%c", hiByte);
+ snprintf(lineBuf, sizeof(lineBuf), "%c", hiByte);
else
- sprintf(lineBuf, ".");
- strcat(asciiStr, lineBuf);
+ snprintf(lineBuf, sizeof(lineBuf), ".");
+ strlcat(asciiStr, lineBuf, sizeof(asciiStr));
if ((loByte > 31) && (loByte < 127))
- sprintf(lineBuf, "%c", loByte);
+ snprintf(lineBuf, sizeof(lineBuf), "%c", loByte);
else
- sprintf(lineBuf, ".");
- strcat(asciiStr, lineBuf);
+ snprintf(lineBuf, sizeof(lineBuf), ".");
+ strlcat(asciiStr, lineBuf, sizeof(asciiStr));
} else {
- sprintf(lineBuf, "%02x ", buffer[address]);
- strcat(dataStr, lineBuf);
+ snprintf(lineBuf, sizeof(lineBuf), "%02x ", buffer[address]);
+ strlcat(dataStr, lineBuf, sizeof(dataStr));
if ((buffer[address] > 31) && (buffer[address] < 127))
- sprintf(lineBuf, "%c", buffer[address]);
+ snprintf(lineBuf, sizeof(lineBuf), "%c", buffer[address]);
else
- sprintf(lineBuf, ".");
- strcat(asciiStr, lineBuf);
+ snprintf(lineBuf, sizeof(lineBuf), ".");
+ strlcat(asciiStr, lineBuf, sizeof(asciiStr));
}
}
printf("%06lx %s %s\n", address - addressPerLine, dataStr, asciiStr);
@@ -578,13 +578,13 @@ int logWrites(char *commandStr, unsigned int address, int data,
char fileName[MAXLEN];
char *fileNamePtr;
- if (log.logging != 1)
+ if (logging.logging != 1)
return(0);
formatStr(commandStr, 6, MAXLEN);
- strcpy(deviceName, device.name);
+ strlcpy(deviceName, device.name, sizeof(deviceName));
if (strcmp(deviceName, "AT90(L)S2343 or Tiny22(L)") == 0)
- strcpy(deviceName, "2343/Tiny22");
+ strlcpy(deviceName, "2343/Tiny22", sizeof(deviceName));
formatStr(deviceName, 12, MAXLEN);
queryBuf = malloc(FLASHBUF_UPPERLIMIT * sizeof (unsigned int));
if (queryBuf == NULL) {
@@ -595,20 +595,20 @@ int logWrites(char *commandStr, unsigned int address, int data,
curTime = time(NULL);
locTime = localtime(&curTime);
- if ((logPtr = fopen(log.logPath, "a")) == NULL) {
+ if ((logPtr = fopen(logging.logPath, "a")) == NULL) {
free(queryBuf);
return(1);
}
fprintf(logPtr, "%s %s ", deviceName, commandStr);
if (strchr(commandStr, 'f') != NULL) {
- strcpy(fileName, path);
+ strlcpy(fileName, path, sizeof(fileName));
fileNamePtr = fileName;
idx = strlen(fileName);
while (idx-- > 0 && fileName[idx] != '\\' && fileName[idx] != '/')
fileNamePtr = &fileName[idx];
formatStr(fileNamePtr, 14, MAXLEN - idx);
fprintf(logPtr, "%s ", fileNamePtr);
- if (log.query) {
+ if (logging.query) {
if (strchr(commandStr, 'p') != NULL) {
readFlashArea(queryBuf, device.flashLimit);
areaChksum = checksum(queryBuf, device.flashLimit);
@@ -667,17 +667,17 @@ int logLocks(unsigned int buffer[], char *lockBits) {
char deviceName[MAXLEN];
char lBits[MAXLEN] = "";
- if (log.logging != 1)
+ if (logging.logging != 1)
return(0);
- sprintf(lBits, "%02lx", strtol(lockBits, NULL, 2));
+ snprintf(lBits, sizeof(lBits), "%02lx", strtol(lockBits, NULL, 2));
- strcpy(deviceName, device.name);
+ strlcpy(deviceName, device.name, sizeof(deviceName));
formatStr(deviceName, 12, MAXLEN);
curTime = time(NULL);
locTime = localtime(&curTime);
- if ((logPtr = fopen(log.logPath, "a")) == NULL)
+ if ((logPtr = fopen(logging.logPath, "a")) == NULL)
return(1);
fprintf(logPtr, "%s -L%s ", deviceName, lBits);
readFlashArea(buffer, device.flashLimit);