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
This commit is contained in:
sthen 2012-03-07 13:14:26 +00:00
parent b0fc72e831
commit 929d19b9ba
4 changed files with 3 additions and 141 deletions

View File

@ -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/ \

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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 <unistd.h>
#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); }