aboutsummaryrefslogtreecommitdiff
path: root/toys/pending
diff options
context:
space:
mode:
Diffstat (limited to 'toys/pending')
-rw-r--r--toys/pending/netstat.c6
-rw-r--r--toys/pending/syslogd.c12
2 files changed, 11 insertions, 7 deletions
diff --git a/toys/pending/netstat.c b/toys/pending/netstat.c
index cbe245ec..88e5bd3b 100644
--- a/toys/pending/netstat.c
+++ b/toys/pending/netstat.c
@@ -173,7 +173,7 @@ static const char *get_pid_name(unsigned long inode)
*/
static void display_data(unsigned rport, char *label, unsigned rxq, unsigned txq, char *lip, char *rip, unsigned state, unsigned long inode)
{
- char *ss_state = "UNKNOWN";
+ char *ss_state = "UNKNOWN", buf[12];
char *state_label[] = {"", "ESTABLISHED", "SYN_SENT", "SYN_RECV", "FIN_WAIT1", "FIN_WAIT2",
"TIME_WAIT", "CLOSE", "CLOSE_WAIT", "LAST_ACK", "LISTEN", "CLOSING", "UNKNOWN"};
if (!strcmp(label, "tcp")) {
@@ -185,7 +185,7 @@ static void display_data(unsigned rport, char *label, unsigned rxq, unsigned txq
if (state == 1) ss_state = state_label[state];
else if (state == 7) ss_state = "";
}
- else if (!strcmp(label, "raw")) ss_state = itoa(state);
+ else if (!strcmp(label, "raw")) sprintf(ss_state = buf, "%u", state);
if ( (toys.optflags & FLAG_W) && (toys.optflags & FLAG_p))
xprintf("%3s %6d %6d %-51s %-51s %-12s%s\n", label, rxq, txq, lip, rip, ss_state, get_pid_name(inode));
@@ -215,7 +215,7 @@ static char *get_servname(int port, char *label)
if (!lport) return xmsprintf("%s", "*");
struct servent *ser = getservbyport(lport, label);
if (ser) return xmsprintf("%s", ser->s_name);
- return xmsprintf("%s", itoa(ntohs(lport)));
+ return xmsprintf("%u", (unsigned)ntohs(lport));
}
/*
* used to convert address into text format.
diff --git a/toys/pending/syslogd.c b/toys/pending/syslogd.c
index 31389191..c2cc34a1 100644
--- a/toys/pending/syslogd.c
+++ b/toys/pending/syslogd.c
@@ -84,11 +84,13 @@ int logger_lookup(int where, char *key)
}
//search the given name and return its value
-static char *dec(int val, CODE *clist)
+static char *dec(int val, CODE *clist, char *buf)
{
for (; clist->c_name; clist++)
if (val == clist->c_val) return clist->c_name;
- return itoa(val);
+ sprintf(buf, "%u", val);
+
+ return buf;
}
/*
@@ -340,8 +342,10 @@ static void logmsg(char *msg, int len)
if (toys.optflags & FLAG_K) len = sprintf(toybuf, "<%d> %s\n", pri, msg);
else {
- facstr = dec(pri & LOG_FACMASK, facilitynames);
- lvlstr = dec(LOG_PRI(pri), prioritynames);
+ char facbuf[12], pribuf[12];
+
+ facstr = dec(pri & LOG_FACMASK, facilitynames, facbuf);
+ lvlstr = dec(LOG_PRI(pri), prioritynames, pribuf);
p = "local";
if (!uname(&uts)) p = uts.nodename;