aboutsummaryrefslogtreecommitdiff
path: root/libexec/ftpd/ftpcmd.y
diff options
context:
space:
mode:
authorYaroslav Tykhiy <ytykhiy@gmail.com>2003-07-09 13:54:33 +0000
committerYaroslav Tykhiy <ytykhiy@gmail.com>2003-07-09 13:54:33 +0000
commite25d3184d0d926dd5a2cf7803c15da7b377814af (patch)
tree2e624d0fe22b1aefbd2c1cb7783e27c2947049ea /libexec/ftpd/ftpcmd.y
parent39b96ba75d7bfc29f121f222416f72ac1d94127b (diff)
downloadsrc-e25d3184d0d926dd5a2cf7803c15da7b377814af.tar.gz
src-e25d3184d0d926dd5a2cf7803c15da7b377814af.zip
Block SIGURG while reading from the control channel.
Rationale: SIGURG is configured by ftpd to interrupt system calls, which is useful during data transfers. However, SIGURG could interrupt I/O on the control channel as well, which was mistaken for the end of the session. A practical example could be aborting the download of a tiny file, when the abort sequence reached ftpd after ftpd had passed the file data to the system and returned to its command loop. Reported by: ceri MFC after: 1 week
Notes
Notes: svn path=/head/; revision=117352
Diffstat (limited to 'libexec/ftpd/ftpcmd.y')
-rw-r--r--libexec/ftpd/ftpcmd.y6
1 files changed, 6 insertions, 0 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y
index 3374439814cc..84c028bab552 100644
--- a/libexec/ftpd/ftpcmd.y
+++ b/libexec/ftpd/ftpcmd.y
@@ -1169,6 +1169,7 @@ getline(char *s, int n, FILE *iop)
{
int c;
register char *cs;
+ sigset_t sset, osset;
cs = s;
/* tmpline may contain saved command from urgent mode interruption */
@@ -1184,6 +1185,10 @@ getline(char *s, int n, FILE *iop)
if (c == 0)
tmpline[0] = '\0';
}
+ /* SIGURG would interrupt stdio if not blocked during the read loop */
+ sigemptyset(&sset);
+ sigaddset(&sset, SIGURG);
+ sigprocmask(SIG_BLOCK, &sset, &osset);
while ((c = getc(iop)) != EOF) {
c &= 0377;
if (c == IAC) {
@@ -1216,6 +1221,7 @@ getline(char *s, int n, FILE *iop)
break;
}
got_eof:
+ sigprocmask(SIG_SETMASK, &osset, NULL);
if (c == EOF && cs == s)
return (NULL);
*cs++ = '\0';