ref: eb0e2965408bc21ef6f53a495f9d6469659c65ec
parent: 46a4dfda7b02dd47e09efba43d960285d1154f7d
author: mkf <mkf@cloud9p.org>
date: Sat Dec 2 18:18:07 EST 2023
id: update to use new itoa
--- a/cmd/id.c
+++ b/cmd/id.c
@@ -13,6 +13,7 @@
int
id_main(int argc, char **argv)
{
+ char *tmp;
ll_t *t;
user_t *u;
@@ -19,6 +20,7 @@
if(argc != 2)
return usage();
+ tmp = malloc(2 << 8);
u = nil;
t = users;
while(t != nil)
@@ -25,11 +27,14 @@
{
u = (user_t*)t->val;
/* i wanted to add a iflag, but let it do both for now */
- if(!strcmp(u->name, argv[1]) || !strcmp(itoa(u->id, 10), argv[1]))
+ if(!strcmp(u->name, argv[1]) || !strcmp(itoa(u->id, tmp, 10), argv[1]))
break;
u = nil;
t = (ll_t*)t->next;
}
+
+ free(tmp);
+
if(u == nil)
{
printf("No such user or id\n");