Hi,
valgrind reports that the socket name is read more than its size, it is
right since it is 64 bytes but 102 are read.
It looks to me that the rest of the code assumes that 102 is the right
size so use it in malloc() too.
The attached patch suffice to shut up valgrind.
Please review and give it some testing.
How to reproduce:
valgrind --tool=memcheck ./uwsgi --http 127.0.0.1:8000
==11685== Invalid read of size 4
==11685== at 0x80533C5: bind_to_unix (socket.c:39)
==11685== by 0x8058C7D: main (uwsgi.c:1014)
==11685== Address 0x78cf10e is 62 bytes inside a block of size 64 alloc'd
==11685== at 0x48DEF50: malloc (vg_replace_malloc.c:236)
==11685== by 0x8059763: main (uwsgi.c:729)
==11685==
uwsgi socket 0 bound to UNIX address 1290963546_11682.sock fd 3
[uWSGI DEBUG] uwsgi socket 0 SO_RCVBUF size: 122880
[uWSGI DEBUG] uwsgi socket 0 SO_SNDBUF size: 122880
your server socket listen backlog is limited to 64 connections
*** Operational MODE: single process ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 11685, cores: 1)
==11682== Thread 2:
==11682== Invalid read of size 4
==11682== at 0x805316E: connect_to_unix (socket.c:231)
==11682== by 0x805CD8F: http_request (http.c:315)
==11682== by 0x490E954: start_thread (pthread_create.c:300)
==11682== by 0x703CE7D: clone (clone.S:130)
==11682== Address 0x78cf110 is 0 bytes after a block of size 64 alloc'd
==11682== at 0x48DEF50: malloc (vg_replace_malloc.c:236)
==11682== by 0x8059763: main (uwsgi.c:729)
==11682==
==11682== Invalid read of size 2
==11682== at 0x8053170: connect_to_unix (socket.c:231)
==11682== by 0x805CD8F: http_request (http.c:315)
==11682== by 0x490E954: start_thread (pthread_create.c:300)
==11682== by 0x703CE7D: clone (clone.S:130)
==11682== Address 0x78cf134 is 12 bytes before a block of size 256 alloc'd
==11682== at 0x48DEF50: malloc (vg_replace_malloc.c:236)
==11682== by 0x805C040: http_loop (http.c:117)
==11682== by 0x8059B4E: main (uwsgi.c:747)
thanks,
riccardo
diff -r a29945ff852b uwsgi.c
--- a/uwsgi.c Sun Nov 28 09:54:31 2010 +0100
+++ b/uwsgi.c Sun Nov 28 18:46:26 2010 +0100
@@ -726,13 +726,13 @@
}
if (!uwsgi.sockets[0].name) {
- uwsgi.sockets[0].name = malloc(64);
+ uwsgi.sockets[0].name = malloc(102);
if (!uwsgi.sockets[0].name) {
uwsgi_error("malloc()");
exit(1);
}
uwsgi.sockets_cnt++;
- snprintf(uwsgi.sockets[0].name, 64, "%d_%d.sock", (int) time(NULL), (int) getpid());
+ snprintf(uwsgi.sockets[0].name, 102, "%d_%d.sock", (int) time(NULL), (int) getpid());
uwsgi_log("using %s as uwsgi protocol socket\n", uwsgi.sockets[0].name);
}
if (uwsgi.http_only) {
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi