From f285b12dcfb3f0cecefe915287c7da0893003b31 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 13 Apr 2014 23:43:32 +0200 Subject: [PATCH] Make strcpy_limit slightly more sane. --- Core/HLE/sceIo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index a1aad26ee0..76607a0038 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -1927,10 +1927,10 @@ u32 sceIoDopen(const char *path) { // For some reason strncpy will fill up the entire output buffer. No reason to do that, // so we use this trivial replacement. -static void strcpy_limit(char *dest, const char *src, int count) { +static void strcpy_limit(char *dest, const char *src, int limit) { int i; - for (i = 0; i < count; i++) { - if (!src[i]) // Do the check afterwards, so we don't exit before copying the null terminator. + for (i = 0; i < limit - 1; i++) { + if (!src[i]) break; dest[i] = src[i]; }