X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=helper.c;h=3615d77fa69cc9935dff4c486505895e8760e98f;hb=a35134d7c0765d863ae56e2c1879fb69b76df368;hp=5bd95fd24dbc8ed66d6826508cf02ed4f9f45a3d;hpb=3f781654282c8c85317394dfd874483c4321fac1;p=authbind.git diff --git a/helper.c b/helper.c index 5bd95fd..3615d77 100644 --- a/helper.c +++ b/helper.c @@ -48,7 +48,7 @@ static void perrorfail(const char *m) { } static void badusage(void) { - fprintf(stderr,"libauthbind's helper: bad usage\n %s\n",rcsid); + fprintf(stderr,"libauthbind's helper: bad usage\n (%s)\n",rcsid); exit(ENOSYS); } @@ -72,6 +72,8 @@ int main(int argc, const char *const *argv) { if (argc != 3) badusage(); addr= strtoul(argv[1],&ep,16); if (*ep || addr&~0x0ffffffffUL) badusage(); port= strtoul(argv[2],&ep,16); if (*ep || port&~0x0ffffUL) badusage(); + hport= htons(port); + if (hport >= IPPORT_RESERVED/2) _exit(EPERM); if (chdir(CONFIGDIR)) perrorfail("chdir " CONFIGDIR); @@ -80,7 +82,6 @@ int main(int argc, const char *const *argv) { saddr.sin_family= AF_INET; saddr.sin_port= port; saddr.sin_addr.s_addr= addr; - hport= htons(port); snprintf(fnbuf,sizeof(fnbuf)-1,"byport/%u",hport); if (!access(fnbuf,X_OK)) authorised();