ftpcmd.y (92090) | ftpcmd.y (92272) |
---|---|
1/* 2 * Copyright (c) 1985, 1988, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 31 unchanged lines hidden (view full) --- 40 41%{ 42 43#ifndef lint 44#if 0 45static char sccsid[] = "@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94"; 46#endif 47static const char rcsid[] = | 1/* 2 * Copyright (c) 1985, 1988, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 31 unchanged lines hidden (view full) --- 40 41%{ 42 43#ifndef lint 44#if 0 45static char sccsid[] = "@(#)ftpcmd.y 8.3 (Berkeley) 4/6/94"; 46#endif 47static const char rcsid[] = |
48 "$FreeBSD: head/libexec/ftpd/ftpcmd.y 92090 2002-03-11 11:48:55Z maxim $"; | 48 "$FreeBSD: head/libexec/ftpd/ftpcmd.y 92272 2002-03-14 16:05:06Z maxim $"; |
49#endif /* not lint */ 50 51#include <sys/param.h> 52#include <sys/socket.h> 53#include <sys/stat.h> 54 55#include <netinet/in.h> 56#include <arpa/ftp.h> 57 58#include <ctype.h> 59#include <errno.h> 60#include <glob.h> 61#include <libutil.h> | 49#endif /* not lint */ 50 51#include <sys/param.h> 52#include <sys/socket.h> 53#include <sys/stat.h> 54 55#include <netinet/in.h> 56#include <arpa/ftp.h> 57 58#include <ctype.h> 59#include <errno.h> 60#include <glob.h> 61#include <libutil.h> |
62#include <limits.h> |
|
62#include <md5.h> 63#include <netdb.h> 64#include <pwd.h> 65#include <signal.h> 66#include <stdio.h> 67#include <stdlib.h> 68#include <string.h> 69#include <syslog.h> --- 34 unchanged lines hidden (view full) --- 104char cbuf[512]; 105char *fromname = (char *) 0; 106 107extern int epsvall; 108 109%} 110 111%union { | 63#include <md5.h> 64#include <netdb.h> 65#include <pwd.h> 66#include <signal.h> 67#include <stdio.h> 68#include <stdlib.h> 69#include <string.h> 70#include <syslog.h> --- 34 unchanged lines hidden (view full) --- 105char cbuf[512]; 106char *fromname = (char *) 0; 107 108extern int epsvall; 109 110%} 111 112%union { |
112 int i; | 113 struct { 114 off_t o; 115 int i; 116 } u; |
113 char *s; 114} 115 116%token 117 A B C E F I 118 L N P R S T 119 ALL 120 --- 8 unchanged lines hidden (view full) --- 129 CDUP STOU SMNT SYST SIZE MDTM 130 LPRT LPSV EPRT EPSV 131 132 UMASK IDLE CHMOD MDFIVE 133 134 LEXERR 135 136%token <s> STRING | 117 char *s; 118} 119 120%token 121 A B C E F I 122 L N P R S T 123 ALL 124 --- 8 unchanged lines hidden (view full) --- 133 CDUP STOU SMNT SYST SIZE MDTM 134 LPRT LPSV EPRT EPSV 135 136 UMASK IDLE CHMOD MDFIVE 137 138 LEXERR 139 140%token <s> STRING |
137%token <i> NUMBER | 141%token <u> NUMBER |
138 | 142 |
139%type check_login octal_number byte_size 140%type check_login_ro check_login_epsv 141%type struct_code mode_code type_code form_code | 143%type <u.i> check_login octal_number byte_size 144%type <u.i> check_login_ro check_login_epsv 145%type <u.i> struct_code mode_code type_code form_code |
142%type <s> pathstring pathname password username 143%type <s> ALL 144 145%start cmd_list 146 147%% 148 149cmd_list --- 180 unchanged lines hidden (view full) --- 330 reply(501, "no LPSV allowed after EPSV ALL"); 331 else if ($2) 332 long_passive("LPSV", PF_UNSPEC); 333 } 334 | EPSV check_login_epsv SP NUMBER CRLF 335 { 336 if ($2) { 337 int pf; | 146%type <s> pathstring pathname password username 147%type <s> ALL 148 149%start cmd_list 150 151%% 152 153cmd_list --- 180 unchanged lines hidden (view full) --- 334 reply(501, "no LPSV allowed after EPSV ALL"); 335 else if ($2) 336 long_passive("LPSV", PF_UNSPEC); 337 } 338 | EPSV check_login_epsv SP NUMBER CRLF 339 { 340 if ($2) { 341 int pf; |
338 switch ($4) { | 342 switch ($4.i) { |
339 case 1: 340 pf = PF_INET; 341 break; 342#ifdef INET6 343 case 2: 344 pf = PF_INET6; 345 break; 346#endif --- 311 unchanged lines hidden (view full) --- 658 if ($3) 659 reply(200, 660 "Current IDLE time limit is %d seconds; max %d", 661 timeout, maxtimeout); 662 } 663 | SITE SP check_login IDLE SP NUMBER CRLF 664 { 665 if ($3) { | 343 case 1: 344 pf = PF_INET; 345 break; 346#ifdef INET6 347 case 2: 348 pf = PF_INET6; 349 break; 350#endif --- 311 unchanged lines hidden (view full) --- 662 if ($3) 663 reply(200, 664 "Current IDLE time limit is %d seconds; max %d", 665 timeout, maxtimeout); 666 } 667 | SITE SP check_login IDLE SP NUMBER CRLF 668 { 669 if ($3) { |
666 if ($6 < 30 || $6 > maxtimeout) { | 670 if ($6.i < 30 || $6.i > maxtimeout) { |
667 reply(501, 668 "Maximum IDLE time must be between 30 and %d seconds", 669 maxtimeout); 670 } else { | 671 reply(501, 672 "Maximum IDLE time must be between 30 and %d seconds", 673 maxtimeout); 674 } else { |
671 timeout = $6; | 675 timeout = $6.i; |
672 (void) alarm((unsigned) timeout); 673 reply(200, 674 "Maximum IDLE time set to %d seconds", 675 timeout); 676 } 677 } 678 } 679 | STOU check_login_ro SP pathname CRLF --- 87 unchanged lines hidden (view full) --- 767 if (renamefrom($4)) 768 fromname = $4; 769 else 770 free($4); 771 } else if ($4) { 772 free($4); 773 } 774 } | 676 (void) alarm((unsigned) timeout); 677 reply(200, 678 "Maximum IDLE time set to %d seconds", 679 timeout); 680 } 681 } 682 } 683 | STOU check_login_ro SP pathname CRLF --- 87 unchanged lines hidden (view full) --- 771 if (renamefrom($4)) 772 fromname = $4; 773 else 774 free($4); 775 } else if ($4) { 776 free($4); 777 } 778 } |
775 | REST check_login SP byte_size CRLF | 779 | REST check_login SP NUMBER CRLF |
776 { 777 if ($2) { 778 if (fromname) 779 free(fromname); 780 fromname = (char *) 0; | 780 { 781 if ($2) { 782 if (fromname) 783 free(fromname); 784 fromname = (char *) 0; |
781 restart_point = $4; /* XXX $4 is only "int" */ 782 reply(350, "Restarting at %qd. %s", | 785 restart_point = $4.o; 786 reply(350, "Restarting at %llu. %s", |
783 restart_point, 784 "Send STORE or RETRIEVE to initiate transfer."); 785 } 786 } 787 ; 788 789username 790 : STRING --- 4 unchanged lines hidden (view full) --- 795 { 796 $$ = (char *)calloc(1, sizeof(char)); 797 } 798 | STRING 799 ; 800 801byte_size 802 : NUMBER | 787 restart_point, 788 "Send STORE or RETRIEVE to initiate transfer."); 789 } 790 } 791 ; 792 793username 794 : STRING --- 4 unchanged lines hidden (view full) --- 799 { 800 $$ = (char *)calloc(1, sizeof(char)); 801 } 802 | STRING 803 ; 804 805byte_size 806 : NUMBER |
807 { 808 $$ = $1.i; 809 } |
|
803 ; 804 805host_port 806 : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 807 NUMBER COMMA NUMBER 808 { 809 char *a, *p; 810 811 data_dest.su_len = sizeof(struct sockaddr_in); 812 data_dest.su_family = AF_INET; 813 p = (char *)&data_dest.su_sin.sin_port; | 810 ; 811 812host_port 813 : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 814 NUMBER COMMA NUMBER 815 { 816 char *a, *p; 817 818 data_dest.su_len = sizeof(struct sockaddr_in); 819 data_dest.su_family = AF_INET; 820 p = (char *)&data_dest.su_sin.sin_port; |
814 p[0] = $9; p[1] = $11; | 821 p[0] = $9.i; p[1] = $11.i; |
815 a = (char *)&data_dest.su_sin.sin_addr; | 822 a = (char *)&data_dest.su_sin.sin_addr; |
816 a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7; | 823 a[0] = $1.i; a[1] = $3.i; a[2] = $5.i; a[3] = $7.i; |
817 } 818 ; 819 820host_long_port 821 : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 822 NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 823 NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 824 NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 825 NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 826 NUMBER 827 { 828 char *a, *p; 829 830 memset(&data_dest, 0, sizeof(data_dest)); 831 data_dest.su_len = sizeof(struct sockaddr_in6); 832 data_dest.su_family = AF_INET6; 833 p = (char *)&data_dest.su_port; | 824 } 825 ; 826 827host_long_port 828 : NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 829 NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 830 NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 831 NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 832 NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 833 NUMBER 834 { 835 char *a, *p; 836 837 memset(&data_dest, 0, sizeof(data_dest)); 838 data_dest.su_len = sizeof(struct sockaddr_in6); 839 data_dest.su_family = AF_INET6; 840 p = (char *)&data_dest.su_port; |
834 p[0] = $39; p[1] = $41; | 841 p[0] = $39.i; p[1] = $41.i; |
835 a = (char *)&data_dest.su_sin6.sin6_addr; | 842 a = (char *)&data_dest.su_sin6.sin6_addr; |
836 a[0] = $5; a[1] = $7; a[2] = $9; a[3] = $11; 837 a[4] = $13; a[5] = $15; a[6] = $17; a[7] = $19; 838 a[8] = $21; a[9] = $23; a[10] = $25; a[11] = $27; 839 a[12] = $29; a[13] = $31; a[14] = $33; a[15] = $35; | 843 a[0] = $5.i; a[1] = $7.i; a[2] = $9.i; a[3] = $11.i; 844 a[4] = $13.i; a[5] = $15.i; a[6] = $17.i; a[7] = $19.i; 845 a[8] = $21.i; a[9] = $23.i; a[10] = $25.i; a[11] = $27.i; 846 a[12] = $29.i; a[13] = $31.i; a[14] = $33.i; a[15] = $35.i; |
840 if (his_addr.su_family == AF_INET6) { 841 /* XXX more sanity checks! */ 842 data_dest.su_sin6.sin6_scope_id = 843 his_addr.su_sin6.sin6_scope_id; 844 } | 847 if (his_addr.su_family == AF_INET6) { 848 /* XXX more sanity checks! */ 849 data_dest.su_sin6.sin6_scope_id = 850 his_addr.su_sin6.sin6_scope_id; 851 } |
845 if ($1 != 6 || $3 != 16 || $37 != 2) | 852 if ($1.i != 6 || $3.i != 16 || $37.i != 2) |
846 memset(&data_dest, 0, sizeof(data_dest)); 847 } 848 | NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 849 NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 850 NUMBER 851 { 852 char *a, *p; 853 854 memset(&data_dest, 0, sizeof(data_dest)); 855 data_dest.su_sin.sin_len = sizeof(struct sockaddr_in); 856 data_dest.su_family = AF_INET; 857 p = (char *)&data_dest.su_port; | 853 memset(&data_dest, 0, sizeof(data_dest)); 854 } 855 | NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 856 NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA 857 NUMBER 858 { 859 char *a, *p; 860 861 memset(&data_dest, 0, sizeof(data_dest)); 862 data_dest.su_sin.sin_len = sizeof(struct sockaddr_in); 863 data_dest.su_family = AF_INET; 864 p = (char *)&data_dest.su_port; |
858 p[0] = $15; p[1] = $17; | 865 p[0] = $15.i; p[1] = $17.i; |
859 a = (char *)&data_dest.su_sin.sin_addr; | 866 a = (char *)&data_dest.su_sin.sin_addr; |
860 a[0] = $5; a[1] = $7; a[2] = $9; a[3] = $11; 861 if ($1 != 4 || $3 != 4 || $13 != 2) | 867 a[0] = $5.i; a[1] = $7.i; a[2] = $9.i; a[3] = $11.i; 868 if ($1.i != 4 || $3.i != 4 || $13.i != 2) |
862 memset(&data_dest, 0, sizeof(data_dest)); 863 } 864 ; 865 866form_code 867 : N 868 { 869 $$ = FORM_N; --- 122 unchanged lines hidden (view full) --- 992 : NUMBER 993 { 994 int ret, dec, multby, digit; 995 996 /* 997 * Convert a number that was read as decimal number 998 * to what it would be if it had been read as octal. 999 */ | 869 memset(&data_dest, 0, sizeof(data_dest)); 870 } 871 ; 872 873form_code 874 : N 875 { 876 $$ = FORM_N; --- 122 unchanged lines hidden (view full) --- 999 : NUMBER 1000 { 1001 int ret, dec, multby, digit; 1002 1003 /* 1004 * Convert a number that was read as decimal number 1005 * to what it would be if it had been read as octal. 1006 */ |
1000 dec = $1; | 1007 dec = $1.i; |
1001 multby = 1; 1002 ret = 0; 1003 while (dec) { 1004 digit = dec%10; 1005 if (digit > 7) { 1006 ret = -1; 1007 break; 1008 } --- 354 unchanged lines hidden (view full) --- 1363 return (SP); 1364 } 1365 if (isdigit(cbuf[cpos])) { 1366 cp = &cbuf[cpos]; 1367 while (isdigit(cbuf[++cpos])) 1368 ; 1369 c = cbuf[cpos]; 1370 cbuf[cpos] = '\0'; | 1008 multby = 1; 1009 ret = 0; 1010 while (dec) { 1011 digit = dec%10; 1012 if (digit > 7) { 1013 ret = -1; 1014 break; 1015 } --- 354 unchanged lines hidden (view full) --- 1370 return (SP); 1371 } 1372 if (isdigit(cbuf[cpos])) { 1373 cp = &cbuf[cpos]; 1374 while (isdigit(cbuf[++cpos])) 1375 ; 1376 c = cbuf[cpos]; 1377 cbuf[cpos] = '\0'; |
1371 yylval.i = atoi(cp); | 1378 yylval.u.i = atoi(cp); |
1372 cbuf[cpos] = c; 1373 state = STR1; 1374 return (NUMBER); 1375 } 1376 state = STR1; 1377 goto dostr1; 1378 1379 case ARGS: 1380 if (isdigit(cbuf[cpos])) { 1381 cp = &cbuf[cpos]; 1382 while (isdigit(cbuf[++cpos])) 1383 ; 1384 c = cbuf[cpos]; 1385 cbuf[cpos] = '\0'; | 1379 cbuf[cpos] = c; 1380 state = STR1; 1381 return (NUMBER); 1382 } 1383 state = STR1; 1384 goto dostr1; 1385 1386 case ARGS: 1387 if (isdigit(cbuf[cpos])) { 1388 cp = &cbuf[cpos]; 1389 while (isdigit(cbuf[++cpos])) 1390 ; 1391 c = cbuf[cpos]; 1392 cbuf[cpos] = '\0'; |
1386 yylval.i = atoi(cp); | 1393 yylval.u.i = atoi(cp); 1394 yylval.u.o = strtoull(cp, (char **)NULL, 10); |
1387 cbuf[cpos] = c; 1388 return (NUMBER); 1389 } 1390 if (strncasecmp(&cbuf[cpos], "ALL", 3) == 0 1391 && !isalnum(cbuf[cpos + 3])) { 1392 cpos += 3; 1393 return ALL; 1394 } --- 304 unchanged lines hidden --- | 1395 cbuf[cpos] = c; 1396 return (NUMBER); 1397 } 1398 if (strncasecmp(&cbuf[cpos], "ALL", 3) == 0 1399 && !isalnum(cbuf[cpos + 3])) { 1400 cpos += 3; 1401 return ALL; 1402 } --- 304 unchanged lines hidden --- |