give a bigger number as a size and add nul byte at the end of array
in case of causing truncation.
Change-Id: I8db4fb74774810b83c2f92bd21ed4d1a0943b063
strncat(p, file, len);
p += len;
*(p++) = '.';
strncat(p, file, len);
p += len;
*(p++) = '.';
p += 3;
*p = '\0';
} else {
p += 3;
*p = '\0';
} else {
len = fread(pname, sizeof(char), TDM_NAME_LEN, h);
if (len == 0) {
len = fread(pname, sizeof(char), TDM_NAME_LEN, h);
if (len == 0) {
- strncpy(pname, "NO NAME", 7);
- len = 8;
+ strncpy(pname, "NO NAME", sizeof(pname));
+ pname[sizeof(pname) - 1] = '\0';
- strncpy(name, pname, size - 1);
+ strncpy(name, pname, size);
name[size - 1] = '\0';
fclose(h);
name[size - 1] = '\0';
fclose(h);
char buffer[TDM_DEBUG_REPLY_MSG_LEN];
int copylen = TDM_MIN(size, sizeof(buffer) - 1);
char buffer[TDM_DEBUG_REPLY_MSG_LEN];
int copylen = TDM_MIN(size, sizeof(buffer) - 1);
- strncpy(buffer, m, copylen);
+ strncpy(buffer, m, sizeof(buffer));
+ buffer[sizeof(buffer) - 1] = '\0';
+
m += copylen;
size -= copylen;
m += copylen;
size -= copylen;
strncat(p, file, len);
p += len;
*(p++) = '.';
strncat(p, file, len);
p += len;
*(p++) = '.';
p += 3;
*p = '\0';
} else {
p += 3;
*p = '\0';
} else {