Introduction
Introduction Statistics Contact Development Disclaimer Help
use BUFSIZ for optimal buffer size, check open return fd - sdhcp - simple dhcp …
git clone git://git.codemadness.org/sdhcp
Log
Files
Refs
LICENSE
---
commit ba2f7b64cceb89657c54733fbfdfb0b127427da1
parent 6d5cb4daf78d159d9a6446183956c7a7086f1b80
Author: Hiltjo Posthuma <[email protected]>
Date: Fri, 25 Apr 2014 22:02:37 +0200
use BUFSIZ for optimal buffer size, check open return fd
Signed-off-by: Hiltjo Posthuma <[email protected]>
Diffstat:
M sdhcp.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/sdhcp.c b/sdhcp.c
@@ -171,14 +171,14 @@ setip(unsigned char ip[4], unsigned char mask[4], unsigne…
static void
cat(int dfd, char *src)
{
- char buf[4096]; /* TODO: use BUFSIZ ? */
- int n, sfd = open(src, O_RDONLY);
+ char buf[BUFSIZ];
+ int n, fd;
- while((n = read(sfd, buf, sizeof buf))>0)
+ if((fd = open(src, O_RDONLY)) == -1)
+ return; /* can't read, but don't error out */
+ while((n = read(fd, buf, sizeof buf)) > 0)
write(dfd, buf, n);
- close(sfd);
-
-}
+ close(fd);
}
static void
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.