The `perror` function returns a printable string corresonding
to the current error.  Ours had an off-by-one bug due to an
incorrect use of `strncpy`.

Change-Id: I54a4314c723aa69480b4ef77da39973a4bbc58a2
Signed-off-by: Dan Cross <[email protected]>
---
 tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/perror.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/perror.c 
b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/perror.c
index 3e23a75..16ad10d 100644
--- a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/perror.c
+++ b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/perror.c
@@ -57,10 +57,11 @@ void
 perror (const char *s)
 {
   int errnum = errno;
-  char errstr_save[MAX_ERRSTR_LEN];
+  char errstr_save[MAX_ERRSTR_LEN + 1];
   FILE *fp;
   int fd = -1;
   strncpy(errstr_save, errstr(), MAX_ERRSTR_LEN);
+  errstr_save[MAX_ERRSTR_LEN] = '\0';
 
   /* The standard says that 'perror' must not change the orientation
      of the stream.  What is supposed to happen when the stream isn't
-- 
2.8.0.rc3.226.g39d4020

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to