uint32_t k;
if (text) {
- sprintf(z, "Index of %s" CRLF, uri);
+ snprintf(z, sizeof(z), "Index of %s" CRLF, uri);
i = strlen(z)-2;
p = z + i + 2;
}
*p = '\0';
- strcat(z, CRLF CRLF
+ strncat(z, CRLF CRLF
"Name Size "
"Date-Time Type" CRLF
"------------------------------------"
- "--------------------------------------------"CRLF);
+ "--------------------------------------------"CRLF, sizeof(z) - strlen(z) - 1);
} else {
- sprintf(z, "<HTML><HEAD><TITLE>Index of %s</TITLE></HEAD><BODY>"
+ snprintf(z, sizeof(z), "<HTML><HEAD><TITLE>Index of %s</TITLE></HEAD><BODY>"
"<H1>Index of %s</H1><PRE>",
uri, uri);
- strcat(z, "Name Size "
- "Date-Time Type<HR WIDTH=100%>"CRLF);
+ strncat(z, "Name Size "
+ "Date-Time Type<HR WIDTH=100%>"CRLF, sizeof(z) - strlen(z) - 1);
}
HTTPWriteBodyChunk(sessionP, z, strlen(z));
else
--i;
- strcpy(z, fi->name);
+ snprintf(z, sizeof(z), "%s", fi->name);
k = strlen(z);
}
if (k > 24) {
- z[10] = '\0';
- strcpy(z1, z);
- strcat(z1, "...");
- strcat(z1, z + k - 11);
+ snprintf(z1, sizeof(z1), "%.10s...%s", z, z + k - 11);
k = 24;
p = z1 + 24;
} else {
- strcpy(z1, z);
+ snprintf(z1, sizeof(z1), "%s", z);
++k;
p = z1 + k;
}
xmlrpc_gmtime(fi->time_write, &ftm);
- sprintf(z2, "%02u/%02u/%04u %02u:%02u:%02u",ftm.tm_mday,ftm.tm_mon+1,
+ snprintf(z2, sizeof(z2), "%02u/%02u/%04u %02u:%02u:%02u",ftm.tm_mday,ftm.tm_mon+1,
ftm.tm_year+1900,ftm.tm_hour,ftm.tm_min,ftm.tm_sec);
if (fi->attrib & A_SUBDIR) {
- strcpy(z3, " -- ");
+ snprintf(z3, sizeof(z3), " -- ");
z4 = "Directory";
} else {
if (fi->size < 9999)
}
}
- sprintf(z3, "%5" PRIu64 " %c", fi->size, u);
+ snprintf(z3, sizeof(z3), "%5" PRIu64 " %c", fi->size, u);
if (xmlrpc_streq(fi->name, ".."))
z4 = "";
}
if (text)
- sprintf(z, "%s%s %s %s %s"CRLF, z1, p, z3, z2, z4);
+ snprintf(z, sizeof(z), "%s%s %s %s %s"CRLF, z1, p, z3, z2, z4);
else
- sprintf(z, "<A HREF=\"%s%s\">%s</A>%s %s %s %s"CRLF,
+ snprintf(z, sizeof(z), "<A HREF=\"%s%s\">%s</A>%s %s %s %s"CRLF,
fi->name, fi->attrib & A_SUBDIR ? "/" : "",
z1, p, z3, z2, z4);
/* Write the tail of the file */
if (text)
- strcpy(z, SERVER_PLAIN_INFO);
+ snprintf(z, sizeof(z), "%s", SERVER_PLAIN_INFO);
else
- strcpy(z, "</PRE>" SERVER_HTML_INFO "</BODY></HTML>" CRLF CRLF);
+ snprintf(z, sizeof(z), "%s", "</PRE>" SERVER_HTML_INFO "</BODY></HTML>" CRLF CRLF);
HTTPWriteBodyChunk(sessionP, z, strlen(z));
}
return TRUE;
}
- strcpy(z, handlerP->filesPath);
- strcat(z, sessionP->requestInfo.uri);
+ snprintf(z, sizeof(z), "%s%s", handlerP->filesPath, sessionP->requestInfo.uri);
p = z + strlen(z) - 1;
if (*p == '/') {
** to avoid problems with some browsers (IE for examples) when
** they generate relative urls */
if (!endingslash) {
- strcpy(z, sessionP->requestInfo.uri);
+ snprintf(z, sizeof(z), "%s", sessionP->requestInfo.uri);
p = z+strlen(z);
*p = '/';
*(p+1) = '\0';
i = handlerP->defaultFileNames.size;
while (i-- > 0) {
*p = '\0';
- strcat(z, (handlerP->defaultFileNames.item[i]));
+ strncat(z, handlerP->defaultFileNames.item[i], sizeof(z) - strlen(z) - 1);
if (FileStat(z, &fs)) {
if (!(fs.st_mode & S_IFDIR))
handleFile(sessionP, z, fs.st_mtime,