aboutsummaryrefslogtreecommitdiffstats
path: root/src/assuan-handler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/assuan-handler.c')
-rw-r--r--src/assuan-handler.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/assuan-handler.c b/src/assuan-handler.c
index 6ddfe88..16838b2 100644
--- a/src/assuan-handler.c
+++ b/src/assuan-handler.c
@@ -154,20 +154,27 @@ parse_cmd_input_output (ASSUAN_CONTEXT ctx, char *line, int *rfd)
{
char *endp;
- if (strncmp (line, "FD=", 3))
- return set_error (ctx, Syntax_Error, "FD=<n> expected");
- line += 3;
- if (!digitp (*line))
- return set_error (ctx, Syntax_Error, "number required");
- *rfd = strtoul (line, &endp, 10);
- /* remove that argument so that a notify handler won't see it */
- memset (line, ' ', endp? (endp-line):strlen(line));
-
- if (*rfd == ctx->inbound.fd)
- return set_error (ctx, Parameter_Conflict, "fd same as inbound fd");
- if (*rfd == ctx->outbound.fd)
- return set_error (ctx, Parameter_Conflict, "fd same as outbound fd");
- return 0;
+ if (strncmp (line, "FD", 2) != 0 || (line[2] != '=' && line[2] != '\0'))
+ return set_error (ctx, Syntax_Error, "FD[=<n>] expected");
+ line += 2;
+ if (*line == '=')
+ {
+ line ++;
+ if (!digitp (*line))
+ return set_error (ctx, Syntax_Error, "number required");
+ *rfd = strtoul (line, &endp, 10);
+ /* remove that argument so that a notify handler won't see it */
+ memset (line, ' ', endp? (endp-line):strlen(line));
+
+ if (*rfd == ctx->inbound.fd)
+ return set_error (ctx, Parameter_Conflict, "fd same as inbound fd");
+ if (*rfd == ctx->outbound.fd)
+ return set_error (ctx, Parameter_Conflict, "fd same as outbound fd");
+ return 0;
+ }
+ else
+ /* Our peer has sent the file descriptor. */
+ return assuan_receivefd (ctx, rfd);
}
/* Format is INPUT FD=<n> */