strlcopy insted of strcpy

This commit is contained in:
roberto@silente
2010-04-30 09:54:25 +02:00
parent 43c086494b
commit 3cdf17df75
4 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -414,7 +414,7 @@ PyObject *py_snmp_community(PyObject * self, PyObject * args) {
memcpy(uwsgi.shared->snmp_community, snmp_community, 72);
}
else {
strcpy(uwsgi.shared->snmp_community, snmp_community);
strlcpy(uwsgi.shared->snmp_community, snmp_community, 73);
}
Py_INCREF(Py_True);
+1 -1
View File
@@ -38,7 +38,7 @@ int bind_to_unix(char *socket_name, int listen_queue, int chmod_socket, int abst
}
uws_addr->sun_family = AF_UNIX;
strcpy(uws_addr->sun_path + abstract_socket, socket_name);
strlcpy(uws_addr->sun_path + abstract_socket, socket_name, 102+1);
if (bind(serverfd, (struct sockaddr *) uws_addr, strlen(socket_name) + abstract_socket + ((void *) uws_addr->sun_path - (void *) uws_addr)) != 0) {
uwsgi_error("bind()");
+2
View File
@@ -133,6 +133,8 @@ void daemonize(char *logfile) {
exit(1);
}
// avoid log mess
setlinebuf(stderr);
close(fd);
+6 -5
View File
@@ -493,7 +493,7 @@ int main(int argc, char *argv[], char *envp[]) {
uwsgi_error("malloc()");
exit(1);
}
strcpy(uwsgi.binary_path, argv[0]);
strlcpy(uwsgi.binary_path, argv[0], strlen(argv[0]) + 1);
}
#ifndef UNBIT
@@ -1073,7 +1073,8 @@ int main(int argc, char *argv[], char *envp[]) {
signal(SIGUSR1, (void *) &stats);
#endif
#ifdef UWSGI_SNMP
uwsgi.wsgi_req->buffer = uwsgi.async_buf[0];
#ifdef UWSGI_UDP
if (uwsgi.udp_socket) {
uwsgi_poll.fd = bind_to_udp(uwsgi.udp_socket);
if (uwsgi_poll.fd < 0) {
@@ -1094,7 +1095,7 @@ int main(int argc, char *argv[], char *envp[]) {
memcpy(uwsgi.shared->snmp_community, uwsgi.snmp_community, 72);
}
else {
strcpy(uwsgi.shared->snmp_community, uwsgi.snmp_community);
strlcpy(uwsgi.shared->snmp_community, uwsgi.snmp_community, 73);
}
}
fprintf(stderr, "filling SNMP table...");
@@ -1233,7 +1234,7 @@ int main(int argc, char *argv[], char *envp[]) {
}
else if (rlen > 0) {
udp_len = sizeof(udp_client);
rlen = recvfrom(uwsgi_poll.fd, &uwsgi.wsgi_req->buffer, uwsgi.buffer_size, 0, (struct sockaddr *) &udp_client, &udp_len);
rlen = recvfrom(uwsgi_poll.fd, uwsgi.wsgi_req->buffer, uwsgi.buffer_size, 0, (struct sockaddr *) &udp_client, &udp_len);
if (rlen < 0) {
uwsgi_error("recvfrom()");
}
@@ -2787,7 +2788,7 @@ void uwsgi_cluster_add_node(char *nodename, int workers) {
ucn = &uwsgi.shared->nodes[i];
if (ucn->name[0] == 0) {
strcpy(ucn->name, nodename);
strlcpy(ucn->name, nodename, 101);
ucn->workers = workers;
ucn->ucn_addr.sin_family = AF_INET;
ucn->ucn_addr.sin_port = htons(atoi(tcp_port + 1));