aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-01-27 17:11:36 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-01-27 17:11:36 -0200
commit8622dc18bfa9da14136763e9538222fdec31a79a (patch)
tree3e554773c46c51d5197c3318069043b79ff3362e
parentd22e2644ddd6535d803ab35bd9ce2e3a5901d2e7 (diff)
downloadlua-8622dc18bfa9da14136763e9538222fdec31a79a.tar.gz
lua-8622dc18bfa9da14136763e9538222fdec31a79a.tar.bz2
lua-8622dc18bfa9da14136763e9538222fdec31a79a.zip
bug: format size limits with little problems
-rw-r--r--bugs6
-rw-r--r--lstrlib.c8
2 files changed, 10 insertions, 4 deletions
diff --git a/bugs b/bugs
index b9c05ca1..d2155964 100644
--- a/bugs
+++ b/bugs
@@ -18,3 +18,9 @@ Thu Jan 15 14:34:58 EDT 1998
18** llex.c 18** llex.c
19Mon Jan 19 18:17:18 EDT 1998 19Mon Jan 19 18:17:18 EDT 1998
20>> wrong line number (+1) in error report when file starts with "#..." 20>> wrong line number (+1) in error report when file starts with "#..."
21
22** lstrlib.c
23Tue Jan 27 15:27:49 EDT 1998
24>> formats like "%020d" were considered too big (3 algarithms); moreover,
25>> some sistems limit printf to at most 500 chars, so we can limit sizes
26>> to 2 digits (99).
diff --git a/lstrlib.c b/lstrlib.c
index 8c963b11..a1b061ed 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.6 1998/01/09 14:44:55 roberto Exp $ 2** $Id: lstrlib.c,v 1.7 1998/01/09 14:57:43 roberto Exp roberto $
3** Standard library for strings and pattern-matching 3** Standard library for strings and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -449,14 +449,14 @@ static void str_format (void)
449 char *initf = strfrmt; 449 char *initf = strfrmt;
450 form[0] = '%'; 450 form[0] = '%';
451 cap.level = 0; 451 cap.level = 0;
452 strfrmt = match(strfrmt, "%d?%$?[-+ #]*(%d*)%.?(%d*)", &cap);
453 if (cap.capture[0].len > 3 || cap.capture[1].len > 3) /* < 1000? */
454 lua_error("invalid format (width or precision too long)");
455 if (isdigit((unsigned char)initf[0]) && initf[1] == '$') { 452 if (isdigit((unsigned char)initf[0]) && initf[1] == '$') {
456 arg = initf[0] - '0'; 453 arg = initf[0] - '0';
457 initf += 2; /* skip the 'n$' */ 454 initf += 2; /* skip the 'n$' */
458 } 455 }
459 arg++; 456 arg++;
457 strfrmt = match(initf, "[-+ #0]*(%d*)%.?(%d*)", &cap);
458 if (cap.capture[0].len > 2 || cap.capture[1].len > 2) /* < 100? */
459 lua_error("invalid format (width or precision too long)");
460 strncpy(form+1, initf, strfrmt-initf+1); /* +1 to include convertion */ 460 strncpy(form+1, initf, strfrmt-initf+1); /* +1 to include convertion */
461 form[strfrmt-initf+2] = 0; 461 form[strfrmt-initf+2] = 0;
462 buff = luaL_openspace(1000); /* to store the formatted value */ 462 buff = luaL_openspace(1000); /* to store the formatted value */