From 0599f873dc2005a0969b9a84fd40d1db9d17054c Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 28 Aug 2003 12:03:15 +0000 Subject: [PATCH] Don't forget to terminate the string --- src/Prep/DemRaw2ascii/rawdem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Prep/DemRaw2ascii/rawdem.c b/src/Prep/DemRaw2ascii/rawdem.c index d80ff85e..888bdbc8 100644 --- a/src/Prep/DemRaw2ascii/rawdem.c +++ b/src/Prep/DemRaw2ascii/rawdem.c @@ -64,7 +64,7 @@ int reads(int fd, char *buf, unsigned int len) { int res; unsigned int i; for (i=0; - (i < len) && ((res = read(fd, &c, 1)) != 0) + (i < (len-1)) && ((res = read(fd, &c, 1)) != 0) && ((c != '\n') && (c != '\r')); i++) buf[i] = c; @@ -72,6 +72,8 @@ int reads(int fd, char *buf, unsigned int len) { if (buf[i] == '\r') buf[i] = '\n'; + buf[++i] = '\0'; + return res; }