urlencode: fix /fd/0 use

This commit is contained in:
cinap_lenrek 2012-10-13 15:35:39 +02:00
parent 68537b7e96
commit 45c0c41280

View file

@ -44,9 +44,12 @@ main(int argc, char *argv[])
} ARGEND;
if(argc == 1){
close(0);
if(open(*argv, OREAD) < 0)
int fd;
fd = open(*argv, OREAD);
if(fd < 0)
sysfatal("%r");
if(fd != 0) dup(fd, 0);
} else if(argc > 1)
usage();