Try to be a nice guy, even if it is a PoC
This commit is contained in:
4
common.h
4
common.h
@@ -31,7 +31,7 @@ static inline void byte_set (void *dst, const char value, size_t size)
|
||||
*d++ = value;
|
||||
}
|
||||
|
||||
static inline void byte_copy (void *dst, const void *src, size_t size)
|
||||
static inline void byte_cpy (void *dst, const void *src, size_t size)
|
||||
{
|
||||
if (!dst || !src)
|
||||
return;
|
||||
@@ -120,7 +120,7 @@ static inline void buffer_shift (buffer_t *buffer)
|
||||
const uint8_t *src = PALIGN_DOWN(buffer->read);
|
||||
const size_t size = ALIGN(buffer->write-src);
|
||||
if (buffer->data+size<src) {
|
||||
byte_copy(buffer->data, src, size);
|
||||
byte_cpy(buffer->data, src, size);
|
||||
buffer->read -= src-buffer->data;
|
||||
buffer->write -= src-buffer->data;
|
||||
}
|
||||
|
||||
16
glorytun.c
16
glorytun.c
@@ -104,7 +104,7 @@ static void gt_sa_stop (int sig)
|
||||
}
|
||||
}
|
||||
|
||||
static int gt_set_signal (void)
|
||||
static void gt_set_signal (void)
|
||||
{
|
||||
struct sigaction sa = {0};
|
||||
|
||||
@@ -119,7 +119,7 @@ static int gt_set_signal (void)
|
||||
sigaction(SIGPIPE, &sa, NULL);
|
||||
}
|
||||
|
||||
static inline int read_to_buffer (int fd, buffer_t *buffer)
|
||||
static int read_to_buffer (int fd, buffer_t *buffer)
|
||||
{
|
||||
buffer_shift(buffer);
|
||||
|
||||
@@ -143,7 +143,7 @@ static inline int read_to_buffer (int fd, buffer_t *buffer)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int write_from_buffer (int fd, buffer_t *buffer)
|
||||
static int write_from_buffer (int fd, buffer_t *buffer)
|
||||
{
|
||||
size_t size = buffer_read_size(buffer);
|
||||
|
||||
@@ -186,14 +186,20 @@ static void option (int argc, char **argv, int n, struct option *opt)
|
||||
continue;
|
||||
switch (opt[k].type) {
|
||||
case option_flag:
|
||||
*(int *)opt[k].data = 1;
|
||||
{
|
||||
const int val = 1;
|
||||
byte_cpy(opt[k].data, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
case option_string:
|
||||
*(char **)opt[k].data = argv[++i];
|
||||
{
|
||||
const char *val = argv[++i];
|
||||
byte_cpy(opt[k].data, &val, sizeof(val));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
|
||||
Reference in New Issue
Block a user