From be54b7f6a2312a007814284b3ae48ed5da892704 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Wed, 15 Jul 2009 15:16:55 +0000 Subject: Revert r21863 partly: fixes Lua git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21883 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/lua/lobject.c | 3 ++- apps/plugins/lua/lstrlib.c | 4 +++- apps/plugins/lua/rockconf.h | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/plugins/lua/lobject.c b/apps/plugins/lua/lobject.c index 7f73114303..62ad8e9359 100644 --- a/apps/plugins/lua/lobject.c +++ b/apps/plugins/lua/lobject.c @@ -181,7 +181,8 @@ const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { void luaO_chunkid (char *out, const char *source, size_t bufflen) { if (*source == '=') { - strlcpy(out, source+1, bufflen); /* remove first char */ + strncpy(out, source+1, bufflen); /* remove first char */ + out[bufflen-1] = '\0'; /* ensures null termination */ } else { /* out = "source", or "...source" */ if (*source == '@') { diff --git a/apps/plugins/lua/lstrlib.c b/apps/plugins/lua/lstrlib.c index 4d58280ba8..3d6103692f 100644 --- a/apps/plugins/lua/lstrlib.c +++ b/apps/plugins/lua/lstrlib.c @@ -737,7 +737,9 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { if (isdigit(uchar(*p))) luaL_error(L, "invalid format (width or precision too long)"); *(form++) = '%'; - strlcpy(form, strfrmt, p - strfrmt + 1); + strncpy(form, strfrmt, p - strfrmt + 1); + form += p - strfrmt + 1; + *form = '\0'; return p; } diff --git a/apps/plugins/lua/rockconf.h b/apps/plugins/lua/rockconf.h index 02bd0e76d1..92c0f8cac8 100644 --- a/apps/plugins/lua/rockconf.h +++ b/apps/plugins/lua/rockconf.h @@ -63,7 +63,6 @@ long pow(long x, long y); #define strchr rb->strchr #define strcmp rb->strcmp #define strcpy rb->strcpy -#define strlcpy rb->strlcpy #define strlen rb->strlen #endif /* _ROCKCONF_H_ */ -- cgit v1.2.3