From: hackbard Date: Sat, 19 Oct 2002 01:33:01 +0000 (+0000) Subject: implemented break through argv[1] prog X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4d20dbc1126c4ddf56d89182c1bd430dc141570;p=my-code%2Fivac.git implemented break through argv[1] prog --- diff --git a/datagram.c b/datagram.c index 72179b7..c288482 100644 --- a/datagram.c +++ b/datagram.c @@ -31,10 +31,11 @@ #include int main(int argc, char *argv[]) { - int send_fd,cmd_fd; + int send_fd; struct sockaddr_in local_addr, remote_addr; socklen_t remote_addr_len,optlen; int send_bytes, read_bytes; + FILE *cmd_fd; if(argc!=4) { printf("usage: %s \"cmd command\" \n",argv[0]); @@ -66,7 +67,7 @@ int main(int argc, char *argv[]) { remote_addr.sin_port=htons(atoi(argv[3])); remote_addr.sin_addr.s_addr=inet_addr(argv[2]); - if((cmd_fd=open(argv[1],O_RDONLY))<0) { + if((cmd_fd=popen(argv[1],"w"))<0) { printf("unable to open file descriptor for %s.\n",argv[1]); exit(1); } @@ -75,8 +76,9 @@ int main(int argc, char *argv[]) { read_bytes=1; while(read_bytes>0) { unsigned char buf[1000]; - read_bytes=read(cmd_fd,buf,sizeof(buf)); + read_bytes=read(0,buf,sizeof(buf)); send_bytes=sendto(send_fd,buf,read_bytes,0,(struct sockaddr *)&remote_addr,remote_addr_len); + fwrite(buf,read_bytes,1,cmd_fd); } close(send_fd);