(doexecute): Use fname(). Simplify convoluted logic. Fix check for
empty argument. Improve error messages.
This commit is contained in:
parent
a81aaba83c
commit
43d66c7d87
1 changed files with 7 additions and 9 deletions
|
@ -266,23 +266,22 @@ doexecute(char *p, FILE *auxfi)
|
||||||
char *tag;
|
char *tag;
|
||||||
|
|
||||||
tag = gettag(p);
|
tag = gettag(p);
|
||||||
while (*p && isspace(*p))
|
|
||||||
p++;
|
|
||||||
if (tag == NULL) {
|
if (tag == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"WARNING! Server attempted unauthorized read of file %s\n",
|
"WARNING! Server attempted unauthorized read of file %s\n",
|
||||||
p);
|
p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (p == NULL) {
|
|
||||||
fprintf(stderr, "Null file to execute\n");
|
|
||||||
free(tag);
|
free(tag);
|
||||||
|
|
||||||
|
p = fname(p);
|
||||||
|
if (*p == 0) {
|
||||||
|
fprintf(stderr, "Need a file to execute\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((fd = open(p, O_RDONLY, 0)) < 0) {
|
if ((fd = open(p, O_RDONLY, 0)) < 0) {
|
||||||
fprintf(stderr, "Can't open execute file\n");
|
fprintf(stderr, "Can't open execute file %s: %s\n",
|
||||||
perror(p);
|
p, strerror(errno));
|
||||||
free(tag);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* copies 4k at a time to the socket */
|
/* copies 4k at a time to the socket */
|
||||||
|
@ -296,7 +295,6 @@ doexecute(char *p, FILE *auxfi)
|
||||||
* sendeof(sock);
|
* sendeof(sock);
|
||||||
*/
|
*/
|
||||||
close(fd);
|
close(fd);
|
||||||
free(tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue