[server] hex_dump() '%' bug fix, minor verbose criteria update

This commit is contained in:
Michael Rash
2014-10-04 16:40:44 -04:00
parent d71f386971
commit 87f3bbdd23
2 changed files with 15 additions and 11 deletions
+7 -4
View File
@@ -95,10 +95,13 @@ _run_extcmd(uid_t user_uid, const char *cmd, char *so_buf, const size_t so_buf_s
memset(argv_new, 0x0, sizeof(argv_new));
if(opts->verbose > 2)
log_msg(LOG_INFO, "run_extcmd(): running CMD: %s", cmd);
if(strtoargv(cmd, argv_new, &argc_new, opts) != 1)
{
log_msg(LOG_ERR,
"run_extcmd: Error converting cmd str to argv via strtoargv()");
"run_extcmd(): Error converting cmd str to argv via strtoargv()");
return(-1);
}
@@ -106,7 +109,7 @@ _run_extcmd(uid_t user_uid, const char *cmd, char *so_buf, const size_t so_buf_s
{
if(pipe(pipe_fd) < 0)
{
log_msg(LOG_ERR, "run_extcmd: pipe() failed: %s", strerror(errno));
log_msg(LOG_ERR, "run_extcmd(): pipe() failed: %s", strerror(errno));
free_argv(argv_new, &argc_new);
return -1;
}
@@ -141,7 +144,7 @@ _run_extcmd(uid_t user_uid, const char *cmd, char *so_buf, const size_t so_buf_s
}
else if(pid == -1)
{
log_msg(LOG_ERR, "run_extcmd: fork() failed: %s", strerror(errno));
log_msg(LOG_ERR, "run_extcmd(): fork() failed: %s", strerror(errno));
free_argv(argv_new, &argc_new);
return -1;
}
@@ -187,7 +190,7 @@ _run_extcmd(uid_t user_uid, const char *cmd, char *so_buf, const size_t so_buf_s
else
{
log_msg(LOG_ERR,
"run_extcmd: could not fdopen() pipe output file descriptor.");
"run_extcmd(): could not fdopen() pipe output file descriptor.");
free_argv(argv_new, &argc_new);
return -1;
}
+8 -7
View File
@@ -30,22 +30,22 @@
#include "log_msg.h"
#include <stdarg.h>
#define ASCII_LEN 17
#define ASCII_LEN 16
/* Generic hex dump function.
*/
void
hex_dump(const unsigned char *data, const int size)
{
int ln, i, j = 0;
char ascii_str[ASCII_LEN] = {0};
int ln=0, i=0, j=0;
char ascii_str[ASCII_LEN+1] = {0};
for(i=0; i<size; i++)
{
if((i % ASCII_LEN-1) == 0)
if((i % ASCII_LEN) == 0)
{
printf(" %s\n 0x%.4x: ", ascii_str, i);
memset(ascii_str, 0x0, ASCII_LEN);
memset(ascii_str, 0x0, ASCII_LEN-1);
j = 0;
}
@@ -62,13 +62,14 @@ hex_dump(const unsigned char *data, const int size)
ln = strlen(ascii_str);
if(ln > 0)
{
for(i=0; i < ASCII_LEN-ln-1; i++)
for(i=0; i < ASCII_LEN-ln; i++)
printf(" ");
if(ln < 8)
printf(" ");
printf(" %s\n\n", ascii_str);
}
return;
}
/* Basic directory checks (stat() and whether the path is actually
@@ -169,7 +170,7 @@ add_argv(char **argv_new, int *argc_new,
{
int buf_size = 0;
if(opts->verbose > 2)
if(opts->verbose > 3)
log_msg(LOG_INFO, "[+] add_argv() + arg: %s", new_arg);
buf_size = strlen(new_arg) + 1;