Commit 8e195849 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

sk-queue: Use int values in getsockopt

The kernel threats them as interger values so
we should declare them this way. Moreover, explicitly
clean them up to eliminate side effects.

Initially I hit a problem where high bits of long "size"
variable was containing some crap from stack and in result
I've got errors like

 | Error (sk-queue.c:102): dump_sk_queue: Can't allocate 171798904800 bytes
 | Error (cr-dump.c:1289): Dump files (pid: 2505) failed with -1
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarStanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c256706a
......@@ -59,14 +59,14 @@ int read_sk_queues(void)
int dump_sk_queue(int sock_fd, int sock_id)
{
struct sk_packet_entry *pe;
unsigned long size;
int ret, size, orig_peek_off;
socklen_t tmp;
int ret, orig_peek_off;
/*
* Save original peek offset.
*/
tmp = sizeof(orig_peek_off);
orig_peek_off = 0;
ret = getsockopt(sock_fd, SOL_SOCKET, SO_PEEK_OFF, &orig_peek_off, &tmp);
if (ret < 0) {
pr_perror("getsockopt failed\n");
......@@ -76,6 +76,7 @@ int dump_sk_queue(int sock_fd, int sock_id)
* Discover max DGRAM size
*/
tmp = sizeof(size);
size = 0;
ret = getsockopt(sock_fd, SOL_SOCKET, SO_SNDBUF, &size, &tmp);
if (ret < 0) {
pr_perror("getsockopt failed\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment