From 929d19b9ba859d52f6b4b4472838b369f10a53e1 Mon Sep 17 00:00:00 2001 From: sthen Date: Wed, 7 Mar 2012 13:14:26 +0000 Subject: [PATCH] Remove local strlcpy/etc patches, we aren't generally patching these in ports any more (they should be addressed upstream instead) and at least some of them are wrong. This fixes a bug found by Piotr Sikora: http://permalink.gmane.org/gmane.os.openbsd.ports/53993 --- lang/lua/Makefile | 4 +- lang/lua/patches/patch-src_lobject_c | 65 ---------------------------- lang/lua/patches/patch-src_lstrlib_c | 55 ----------------------- lang/lua/patches/patch-src_luaconf_h | 20 +-------- 4 files changed, 3 insertions(+), 141 deletions(-) delete mode 100644 lang/lua/patches/patch-src_lobject_c delete mode 100644 lang/lua/patches/patch-src_lstrlib_c diff --git a/lang/lua/Makefile b/lang/lua/Makefile index f19d20e5bd1..8bbd7d0a4f6 100644 --- a/lang/lua/Makefile +++ b/lang/lua/Makefile @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile,v 1.43 2011/12/04 21:12:19 sthen Exp $ +# $OpenBSD: Makefile,v 1.44 2012/03/07 13:14:26 sthen Exp $ COMMENT= powerful, light-weight programming language DISTNAME= lua-5.1.4 -REVISION= 3 +REVISION= 4 CATEGORIES= lang MASTER_SITES= http://www.lua.org/ftp/ \ diff --git a/lang/lua/patches/patch-src_lobject_c b/lang/lua/patches/patch-src_lobject_c deleted file mode 100644 index e4f104e6fce..00000000000 --- a/lang/lua/patches/patch-src_lobject_c +++ /dev/null @@ -1,65 +0,0 @@ -$OpenBSD: patch-src_lobject_c,v 1.3 2007/10/29 20:30:32 espie Exp $ ---- src/lobject.c.orig Fri Feb 10 18:43:52 2006 -+++ src/lobject.c Mon Oct 29 21:26:20 2007 -@@ -142,7 +142,7 @@ const char *luaO_pushvfstring (lua_State *L, const cha - } - case 'p': { - char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ -- sprintf(buff, "%p", va_arg(argp, void *)); -+ snprintf(buff, sizeof(buff), "%p", va_arg(argp, void *)); - pushstr(L, buff); - break; - } -@@ -180,35 +180,33 @@ const char *luaO_pushfstring (lua_State *L, const char - - - void luaO_chunkid (char *out, const char *source, size_t bufflen) { -- if (*source == '=') { -- strncpy(out, source+1, bufflen); /* remove first char */ -- out[bufflen-1] = '\0'; /* ensures null termination */ -- } -+ if (*source == '=') -+ strlcpy(out, source+1, bufflen); /* remove first char */ - else { /* out = "source", or "...source" */ - if (*source == '@') { -- size_t l; -+ size_t l, m; - source++; /* skip the `@' */ -- bufflen -= sizeof(" '...' "); - l = strlen(source); -- strcpy(out, ""); -- if (l > bufflen) { -- source += (l-bufflen); /* get last part of file name */ -- strcat(out, "..."); -+ m = bufflen - sizeof(" '...' "); -+ strlcpy(out, "", bufflen); -+ if (l > m) { -+ source += (l-m); /* get last part of file name */ -+ strlcat(out, "...", bufflen); - } -- strcat(out, source); -+ strlcat(out, source, bufflen); - } - else { /* out = [string "string"] */ -- size_t len = strcspn(source, "\n\r"); /* stop at first newline */ -- bufflen -= sizeof(" [string \"...\"] "); -- if (len > bufflen) len = bufflen; -- strcpy(out, "[string \""); -+ size_t pos = strcspn(source, "\n\r"); /* stop at first newline */ -+ size_t len = bufflen - sizeof(" [string \"...\"] "); -+ if (pos > len) pos = len; -+ strlcpy(out, "[string \"", bufflen); - if (source[len] != '\0') { /* must truncate? */ -- strncat(out, source, len); -- strcat(out, "..."); -+ strlcat(out, source, len); -+ strlcat(out, "...", bufflen); - } - else -- strcat(out, source); -- strcat(out, "\"]"); -+ strlcat(out, source, bufflen); -+ strlcat(out, "\"]", bufflen); - } - } - } diff --git a/lang/lua/patches/patch-src_lstrlib_c b/lang/lua/patches/patch-src_lstrlib_c deleted file mode 100644 index a2281bf33c9..00000000000 --- a/lang/lua/patches/patch-src_lstrlib_c +++ /dev/null @@ -1,55 +0,0 @@ -$OpenBSD: patch-src_lstrlib_c,v 1.4 2011/08/25 07:02:42 jasper Exp $ ---- src/lstrlib.c.orig Wed Aug 24 22:24:32 2011 -+++ src/lstrlib.c Wed Aug 24 22:24:32 2011 -@@ -746,10 +746,9 @@ static const char *scanformat (lua_State *L, const cha - - static void addintlen (char *form) { - size_t l = strlen(form); -- char spec = form[l - 1]; -- strcpy(form + l - 1, LUA_INTFRMLEN); -- form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; -- form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; -+ char spec[3] = { 'l', form[l - 1], '\0' }; -+ form[l - 1] = '\0'; -+ strlcat(form, spec, MAX_FORMAT); - } - - -@@ -774,22 +773,24 @@ static int str_format (lua_State *L) { - strfrmt = scanformat(L, strfrmt, form); - switch (*strfrmt++) { - case 'c': { -- sprintf(buff, form, (int)luaL_checknumber(L, arg)); -+ snprintf(buff, sizeof(buff), form, (int)luaL_checknumber(L, arg)); - break; - } - case 'd': case 'i': { - addintlen(form); -- sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); -+ snprintf(buff, sizeof(buff), form, -+ (LUA_INTFRM_T)luaL_checknumber(L, arg)); - break; - } - case 'o': case 'u': case 'x': case 'X': { - addintlen(form); -- sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); -+ snprintf(buff, sizeof(buff), form, -+ (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); - break; - } - case 'e': case 'E': case 'f': - case 'g': case 'G': { -- sprintf(buff, form, (double)luaL_checknumber(L, arg)); -+ snprintf(buff, sizeof(buff), form, (double)luaL_checknumber(L, arg)); - break; - } - case 'q': { -@@ -807,7 +808,7 @@ static int str_format (lua_State *L) { - continue; /* skip the `addsize' at the end */ - } - else { -- sprintf(buff, form, s); -+ snprintf(buff, sizeof(buff), form, s); - break; - } - } diff --git a/lang/lua/patches/patch-src_luaconf_h b/lang/lua/patches/patch-src_luaconf_h index e641b3cdc1b..f2960822995 100644 --- a/lang/lua/patches/patch-src_luaconf_h +++ b/lang/lua/patches/patch-src_luaconf_h @@ -1,4 +1,4 @@ -$OpenBSD: patch-src_luaconf_h,v 1.4 2008/04/19 17:59:32 okan Exp $ +$OpenBSD: patch-src_luaconf_h,v 1.5 2012/03/07 13:14:27 sthen Exp $ --- src/luaconf.h.orig Fri Jan 18 18:07:48 2008 +++ src/luaconf.h Mon Mar 24 13:53:08 2008 @@ -33,7 +33,7 @@ @@ -10,21 +10,3 @@ $OpenBSD: patch-src_luaconf_h,v 1.4 2008/04/19 17:59:32 okan Exp $ #define LUA_USE_POSIX #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ #define LUA_USE_READLINE /* needs some extra libraries */ -@@ -520,7 +520,7 @@ - */ - #define LUA_NUMBER_SCAN "%lf" - #define LUA_NUMBER_FMT "%.14g" --#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) -+#define lua_number2str(s,n) snprintf((s), sizeof((s)), LUA_NUMBER_FMT, (n)) - #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ - #define lua_str2number(s,p) strtod((s), (p)) - -@@ -647,7 +647,7 @@ union luai_Cast { double l_d; long l_l; }; - #include - #define LUA_TMPNAMBUFSIZE 32 - #define lua_tmpnam(b,e) { \ -- strcpy(b, "/tmp/lua_XXXXXX"); \ -+ strlcpy(b, "/tmp/lua_XXXXXX", sizeof(b)); \ - e = mkstemp(b); \ - if (e != -1) close(e); \ - e = (e == -1); }