[srvx-commits] CVS: services/src opserv.c,1.348,1.349
Brought to you by:
entrope
From: Adrian D. <sai...@us...> - 2003-11-08 20:11:58
|
Update of /cvsroot/srvx/services/src In directory sc8-pr-cvs1:/tmp/cvs-serv5124 Modified Files: opserv.c Log Message: Greatly improve input error checking for addtrust Index: opserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/opserv.c,v retrieving revision 1.348 retrieving revision 1.349 diff -C2 -r1.348 -r1.349 *** opserv.c 28 Oct 2003 04:55:56 -0000 1.348 --- opserv.c 8 Nov 2003 20:11:49 -0000 1.349 *************** *** 142,146 **** #define OSMSG_NOT_EXEMPT "$b%s$b is not on the exempt list." #define OSMSG_ALREADY_TRUSTED "Host $b%s$b is already trusted (use $bdeltrust$b and then $baddtrust$b to adjust)." ! #define OSMSG_HOSTNAME_ONLY "Please only use the hostname, and no ident part." #define OSMSG_ADDED_TRUSTED "Added trusted hosts to the trusted-hosts list." #define OSMSG_REMOVED_TRUSTED "Removed trusted hosts from the trusted-hosts list." --- 142,147 ---- #define OSMSG_NOT_EXEMPT "$b%s$b is not on the exempt list." #define OSMSG_ALREADY_TRUSTED "Host $b%s$b is already trusted (use $bdeltrust$b and then $baddtrust$b to adjust)." ! #define OSMSG_BAD_IP "$b%s$b is not a valid IP address" ! #define OSMSG_BAD_NUMBER "$b%s$b is not a number" #define OSMSG_ADDED_TRUSTED "Added trusted hosts to the trusted-hosts list." #define OSMSG_REMOVED_TRUSTED "Removed trusted hosts from the trusted-hosts list." *************** *** 2070,2085 **** { unsigned long interval; ! char *reason; if (dict_find(opserv_trusted_hosts, argv[1], NULL)) { return opserv_notice(user, OSMSG_ALREADY_TRUSTED, argv[1]); } ! if (strchr(argv[1], '@')) { ! reply(OSMSG_HOSTNAME_ONLY); return 0; } ! reason = unsplit_string(argv+4, argc-4, NULL); interval = ParseInterval(argv[3]); ! opserv_add_trusted_host(argv[1], strtoul(argv[2], NULL, 0), user->handle_info->handle, now, interval ? (now + interval) : 0, reason); return opserv_notice(user, OSMSG_ADDED_TRUSTED); } --- 2071,2102 ---- { unsigned long interval; ! char *reason, *tmp; ! struct in_addr tmpaddr; ! int count; if (dict_find(opserv_trusted_hosts, argv[1], NULL)) { return opserv_notice(user, OSMSG_ALREADY_TRUSTED, argv[1]); } ! ! if (!inet_aton(argv[1], &tmpaddr)) { ! reply(OSMSG_BAD_IP, argv[1]); return 0; } ! ! count = strtoul(argv[2], &tmp, 10); ! if (*tmp != '\0') { ! reply(OSMSG_BAD_NUMBER, argv[2]); ! return 0; ! } ! interval = ParseInterval(argv[3]); ! if (interval == 0 && strcmp(argv[3], "0")) { ! reply(MSG_INVALID_DURATION, argv[3]); ! return 0; ! } ! ! reason = unsplit_string(argv+4, argc-4, NULL); ! ! opserv_add_trusted_host(argv[1], count, user->handle_info->handle, now, interval ? (now + interval) : 0, reason); return opserv_notice(user, OSMSG_ADDED_TRUSTED); } |