This fixes the most gapping secutiy holes in friendsd. Still: just run it chrooted, be carefull. --md@hudora.de --- gpsdrive-2.04-orig/src/friendsd.c Fri Jul 25 14:17:14 2003 +++ gpsdrive-2.04/src/friendsd.c Fri Oct 10 07:03:11 2003 @@ -47,6 +47,7 @@ #include #include #include +#include #define SERV_UDP_PORT 50123 @@ -76,8 +77,8 @@ struct { - char id[30]; - char txt[200]; + char id[31]; + char txt[201]; } *list; static int listnum = 0; @@ -94,8 +95,8 @@ socklen_t clilen; struct hostent *hostname; struct sockaddr_in sin; - char id[30], name[40], lat[40], longi[40], timesec[40], speed[10], - heading[10]; + char id[31], name[41], lat[41], longi[41], timesec[41], speed[11], + heading[11]; for (;;) { @@ -114,7 +115,7 @@ { /* found POS string */ e = - sscanf (mesg, "POS: %s %s %s %s %s %s %s", id, name, lat, + sscanf (mesg, "POS: %30s %40s %40s %40s %40s %10s %10s", id, name, lat, longi, timesec, speed, heading); /* printf("\nGot %d arguments\n",e); */ if (e == 7) @@ -127,16 +128,23 @@ if ((strcmp ((list + i)->id, id)) == 0) { newclient = 0; - strcpy ((list + i)->txt, mesg); + strncpy ((list + i)->txt, mesg, 200); } } if (newclient) { /* new id found */ + if (listnum < MAXLISTENTRIES) + { listnum++; - strcpy ((list + i)->txt, mesg); - strcpy ((list + i)->id, id); + strncpy ((list + i)->txt, mesg, 200); + strncpy ((list + i)->id, id, 30); + } + else + { + printf ("can't add client to list - list is full"); + } } } @@ -243,6 +251,11 @@ struct sockaddr_in serv_addr, cli_addr; pname = argv[0]; + if (geteuid() == 0) + { + printf ("server: please don't run me as root\n"); + exit (1); + } printf ("\nGpsDrive 2.x friendsd server Version 2, listening on UDP port %d...\n",