s:get now truncates strings longer than TempStringMax rather than allowing for overwriting memory beyond the current string buffer

FossilOrigin-Name: 1d4dada029a4caa048c170c52a1af5c72c6bca2c7c2e9e8240e32d648bf42c19
This commit is contained in:
crc 2024-08-05 18:48:57 +00:00
parent 704d400029
commit 5b5609688c
3 changed files with 62 additions and 58 deletions

View file

@ -27,6 +27,7 @@
- `s:get-word` was not properly breaking on space; this is
now corrected
- `n:put` no longer uses temporary string buffers
- `s:get` now truncates strings longer than `TempStringMax`
- library

View file

@ -17,7 +17,9 @@ not `TRUE` it will add the character to the buffer.
~~~
{{
(c-cf) :edit? dup [ ASCII:BS eq? ] [ ASCII:DEL eq? ] bi or ;
(c-) :gather edit? &drop &buffer:add choose ;
(-f) :ended? buffer:size @TempStringMax gteq? ;
(c-) :add ended? &drop &buffer:add choose ;
(c-) :gather edit? &drop &add choose ;
(q-qc) :cycle repeat c:get dup-pair swap call not 0; drop gather again ;
---reveal---
:parse-until (q-s)

View file

@ -10,8 +10,8 @@
#define CELL_MAX LLONG_MAX - 1
#endif
#endif
CELL ngaImageCells = 21062;
CELL ngaImage[] = { 1793,11587,21024,21061,202409,417,389,1249,1535,0,11633,0,10,1,10,2,10,3,10,
CELL ngaImageCells = 21099;
CELL ngaImage[] = { 1793,11587,21061,21098,202409,417,389,1249,1535,0,11633,0,10,1,10,2,10,3,10,
4,10,5,10,6,10,7,10,8,10,11,10,12,10,13,10,14,10,15,10,
16,10,17,10,18,10,19,10,20,10,21,10,22,10,23,10,24,10,25,68223234,
1,2575,85000450,1,656912,163,180,268505089,65,64,285281281,0,65,2063,10,101384453,0,9,10,68485378,
@ -20,7 +20,7 @@ CELL ngaImage[] = { 1793,11587,21024,21061,202409,417,389,1249,1535,0,11633,0,10
1,251790353,101777669,1,17565186,109,524545,113,66,167838467,-1,134287105,3,61,659457,3,459023,130,2049,58,
25,2049,130,1793,137,2049,137,117506307,0,130,0,524545,28,135,168820993,0,149,1642241,149,134283523,
13,135,1793,130,524545,2049,130,1793,130,16846593,149,163,180,1793,66,16846593,149,135,180,1793,
66,7,10,659713,1,659713,2,659713,3,659713,4,659713,5,1793,20331,17108737,3,2,524559,130,
66,7,10,659713,1,659713,2,659713,3,659713,4,659713,5,1793,20368,17108737,3,2,524559,130,
2049,130,2049,130,524545,0,130,524545,0,130,2049,144,1048838,2,1642241,10,7,19872,8246457295145463473,167841793,
216,11,17826049,0,216,2,15,25,524546,18781,134287105,217,29,2305,218,459023,226,2049,4819,134287361,
217,221,659201,216,10,659969,7,2049,58,25,17694978,58,244,9,84152833,48,319750404,243,117507601,246,
@ -170,7 +170,7 @@ CELL ngaImage[] = { 1793,11587,21024,21061,202409,417,389,1249,1535,0,11633,0,10
110,58,105,110,99,0,659713,1,10,3114,3139,168,12482,210720197721,110,58,100,101,99,0,
659969,1,10,3128,3158,168,12482,8246617666422322998,110,58,98,101,116,119,101,101,110,63,0,67503109,
1793,3166,67503109,67503109,2049,3106,10,1,3161,2049,2241,11,10,3142,3187,168,12482,249861296566813883,83,99,
111,112,101,76,105,115,116,0,20746,20859,10,3172,3198,168,12482,5864091,123,123,0,2049,
111,112,101,76,105,115,116,0,20783,20896,10,3172,3198,168,12482,5864091,123,123,0,2049,
1576,2,1,3187,2049,61,16,10,3190,3225,168,12482,-6305314778776785742,45,45,45,114,101,118,101,
97,108,45,45,45,0,2049,1576,1,3187,2049,3125,16,10,3207,3241,168,12482,5864159,125,
125,0,1,3187,2049,58,4,15,11,1793,3255,3841,3187,4097,2,10,1,3250,1793,3281,
@ -1004,64 +1004,65 @@ CELL ngaImage[] = { 1793,11587,21024,21061,202409,417,389,1249,1535,0,11633,0,10
82,82,79,82,58,32,76,105,98,114,97,114,121,32,96,37,115,96,32,119,
97,115,32,110,111,116,32,102,111,117,110,100,0,1,19798,2049,8219,2049,10866,2049,
10823,10,1,19796,2049,66,10,105,110,116,101,114,102,97,99,101,47,108,105,98,
114,97,114,121,46,114,101,116,114,111,0,19846,11793,19764,19888,168,20095,8246457295145463473,105,109,
114,97,114,121,46,114,101,116,114,111,0,19846,11793,19764,19888,168,20132,8246457295145463473,105,109,
97,103,101,58,115,97,118,101,0,1,1000,2049,10760,2049,10741,10,19872,19906,168,0,
210711039690,101,100,105,116,63,0,2,1793,19913,1,8,11,10,1,19909,1793,19921,1,127,
11,10,1,19917,2049,2255,22,10,19895,19939,168,0,6953539406400,103,97,116,104,101,114,0,
2049,19906,1,17,1,4079,2049,66,10,19927,19959,168,0,210709415765,99,121,99,108,101,0,
2049,11018,2049,2217,4,8,2049,2644,25,3,2049,19939,1,19959,7,10,19872,19992,168,20095,
-4557881830897049127,112,97,114,115,101,45,117,110,116,105,108,0,1793,20004,2049,4396,2049,4179,2049,
19959,771,2049,4041,10,1,19994,2049,4205,10,19975,20020,168,20095,210726130610,115,58,103,101,116,
0,1793,20042,1793,20028,1,13,11,10,1,20024,1793,20036,1,10,11,10,1,20032,2049,
2255,22,10,1,20022,2049,19992,10,20009,20058,168,20095,210708950412,99,108,101,97,114,0,2049,
4417,92,94,91,50,74,92,94,91,48,59,48,72,0,1,20060,2049,8219,2049,10866,
10,20047,20088,180,20095,5861507,47,47,0,2049,17452,1,11052,2049,3868,10,105,110,116,101,
114,102,97,99,101,47,114,101,116,114,111,45,117,110,105,120,46,114,101,116,
114,111,0,20080,20135,156,0,229441520490121,83,111,117,114,99,101,115,0,3,20384,20578,20769,
11,10,1,19917,2049,2255,22,10,19895,19939,168,0,6953475974244,101,110,100,101,100,63,0,
2049,4157,3841,4262,2049,2675,10,19927,19955,168,0,193486030,97,100,100,0,2049,19939,1,17,
1,4079,2049,66,10,19946,19976,168,0,6953539406400,103,97,116,104,101,114,0,2049,19906,1,
17,1,19955,2049,66,10,19964,19996,168,0,210709415765,99,121,99,108,101,0,2049,11018,2049,
2217,4,8,2049,2644,25,3,2049,19976,1,19996,7,10,19872,20029,168,20132,-4557881830897049127,112,97,
114,115,101,45,117,110,116,105,108,0,1793,20041,2049,4396,2049,4179,2049,19996,771,2049,
4041,10,1,20031,2049,4205,10,20012,20057,168,20132,210726130610,115,58,103,101,116,0,1793,20079,
1793,20065,1,13,11,10,1,20061,1793,20073,1,10,11,10,1,20069,2049,2255,22,10,
1,20059,2049,20029,10,20046,20095,168,20132,210708950412,99,108,101,97,114,0,2049,4417,92,94,
91,50,74,92,94,91,48,59,48,72,0,1,20097,2049,8219,2049,10866,10,20084,20125,
180,20132,5861507,47,47,0,2049,17452,1,11052,2049,3868,10,105,110,116,101,114,102,97,
99,101,47,114,101,116,114,111,45,117,110,105,120,46,114,101,116,114,111,0,
20117,20172,156,0,229441520490121,83,111,117,114,99,101,115,0,3,20421,20615,20806,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,20122,20275,168,0,6953711201841,107,110,111,119,110,63,0,2,1,20135,2049,
9059,10,20263,20292,168,0,210716136861,105,110,100,101,120,0,1,20135,4,2049,9699,1,20135,
4,2049,9205,10,20281,20315,168,0,6953974036516,114,101,99,111,114,100,0,2049,4445,2,1,
20135,2049,3816,3841,20135,1,20135,17,16,10,1793,20382,2049,17387,2049,20275,1793,20340,2049,20292,
10,1,20337,1793,20347,2049,20315,10,1,20344,2049,66,1793,20360,1,192,1,2,17,8,
10,1,20353,2049,2229,2049,1576,2049,186,16,2049,1576,2049,190,3841,11618,8,2049,1576,2049,
188,16,10,1,20331,100,105,99,116,45,119,111,114,100,115,45,108,105,115,116,
105,110,103,46,102,111,114,116,104,0,20080,20422,168,20384,229461403550098,100,58,119,111,114,
100,115,0,1793,20431,2049,190,2049,10866,2049,10836,10,1,20424,2049,8464,10,20409,20454,168,
20384,-3502157631813457253,100,58,119,111,114,100,115,45,119,105,116,104,0,2049,1977,2049,5517,1793,
20485,2049,190,2,2049,1977,2049,5230,1793,20474,2049,10866,2049,10836,10,1,20469,1793,20480,3,
10,1,20478,2049,66,10,1,20460,2049,8464,10,20436,20511,168,20384,2818131571306626127,100,105,115,112,
108,97,121,45,105,102,45,108,101,102,116,0,2,2049,1977,2049,5463,1793,20523,2049,
10866,2049,10836,10,1,20518,1793,20529,3,10,1,20527,2049,66,10,20436,20562,168,20384,2947807019553410009,
100,58,119,111,114,100,115,45,98,101,103,105,110,110,105,110,103,45,119,105,
116,104,0,2049,1977,2049,5517,1793,20573,2049,190,2049,20511,10,1,20568,2049,8464,10,101,
120,116,101,110,115,105,111,110,115,47,100,111,117,98,108,101,46,114,101,116,
114,111,0,20534,20618,168,20578,8246228896775126019,100,111,117,98,108,101,58,118,97,114,0,2049,
2075,4,2049,130,2049,130,10,20602,20644,168,20578,-3421095308458227740,100,111,117,98,108,101,58,102,
101,116,99,104,0,2049,58,4,15,10,20626,20667,168,20578,-3421095308442276665,100,111,117,98,108,
101,58,115,116,111,114,101,0,1,19,2049,2229,2049,61,16,10,20649,20693,168,20578,
-3421095308461432127,100,111,117,98,108,101,58,99,111,110,115,116,0,2049,20618,1,20644,2049,8433,
10,20675,20717,168,20578,-4575607512064199915,100,111,117,98,108,101,58,115,119,97,112,0,67503109,5,
67503109,6,10,20700,20738,168,20578,8246228896775106679,100,111,117,98,108,101,58,100,105,112,0,67503109,
67503109,5,5,8,6,6,10,20722,20762,168,20578,8246228896775123014,100,111,117,98,108,101,58,115,
105,112,0,1,2217,2049,2229,2049,20738,10,101,120,116,101,110,115,105,111,110,115,
47,109,97,108,108,111,99,46,114,101,116,114,111,0,20746,20809,168,20769,8246632143337714634,109,
101,109,58,105,110,118,111,107,101,0,1,15,2049,10760,2049,10741,10,20793,0,156,
20769,210667451248,65,76,76,79,67,0,20816,1,156,20769,6384048135,70,82,69,69,0,20827,2,
156,20769,210689088690,83,84,79,82,69,0,20837,3,156,20769,210673137615,70,69,84,67,72,0,
20848,4,156,20769,6952683137271,82,69,83,73,90,69,0,20746,20886,168,20769,249897943727936361,109,101,109,
58,97,108,108,111,99,0,1,0,2049,20809,10,20871,20906,168,20769,249897943749573803,109,101,109,
58,115,116,111,114,101,0,1,2,2049,20809,10,20891,20926,168,20769,249897943733622728,109,101,109,
58,102,101,116,99,104,0,1,3,2049,20809,10,20911,20945,168,20769,7572664961638592,109,101,109,
58,102,114,101,101,0,1,1,2049,20809,10,20931,20966,168,20769,8246632143679146032,109,101,109,58,
114,101,115,105,122,101,0,1,4,2049,20809,10,20950,20986,168,20769,249897943730056489,109,101,109,
58,99,101,108,108,43,0,1,8,19,17,10,20971,21013,168,20769,1050530996183190288,109,101,109,
58,102,101,116,99,104,45,100,111,117,98,108,101,0,2,1,1,2049,20986,15,
5,2049,20926,6,10,20991,21046,168,20769,1730340976492540563,109,101,109,58,115,116,111,114,101,45,
100,111,117,98,108,101,0,5,5,2049,2217,1,1,2049,20986,6,2049,20906,6,2049,
20906,10,0 };
0,20159,20312,168,0,6953711201841,107,110,111,119,110,63,0,2,1,20172,2049,9059,10,20300,
20329,168,0,210716136861,105,110,100,101,120,0,1,20172,4,2049,9699,1,20172,4,2049,9205,
10,20318,20352,168,0,6953974036516,114,101,99,111,114,100,0,2049,4445,2,1,20172,2049,3816,
3841,20172,1,20172,17,16,10,1793,20419,2049,17387,2049,20312,1793,20377,2049,20329,10,1,20374,
1793,20384,2049,20352,10,1,20381,2049,66,1793,20397,1,192,1,2,17,8,10,1,20390,
2049,2229,2049,1576,2049,186,16,2049,1576,2049,190,3841,11618,8,2049,1576,2049,188,16,10,
1,20368,100,105,99,116,45,119,111,114,100,115,45,108,105,115,116,105,110,103,
46,102,111,114,116,104,0,20117,20459,168,20421,229461403550098,100,58,119,111,114,100,115,0,
1793,20468,2049,190,2049,10866,2049,10836,10,1,20461,2049,8464,10,20446,20491,168,20421,-3502157631813457253,100,
58,119,111,114,100,115,45,119,105,116,104,0,2049,1977,2049,5517,1793,20522,2049,190,
2,2049,1977,2049,5230,1793,20511,2049,10866,2049,10836,10,1,20506,1793,20517,3,10,1,20515,
2049,66,10,1,20497,2049,8464,10,20473,20548,168,20421,2818131571306626127,100,105,115,112,108,97,121,
45,105,102,45,108,101,102,116,0,2,2049,1977,2049,5463,1793,20560,2049,10866,2049,10836,
10,1,20555,1793,20566,3,10,1,20564,2049,66,10,20473,20599,168,20421,2947807019553410009,100,58,119,
111,114,100,115,45,98,101,103,105,110,110,105,110,103,45,119,105,116,104,0,
2049,1977,2049,5517,1793,20610,2049,190,2049,20548,10,1,20605,2049,8464,10,101,120,116,101,
110,115,105,111,110,115,47,100,111,117,98,108,101,46,114,101,116,114,111,0,
20571,20655,168,20615,8246228896775126019,100,111,117,98,108,101,58,118,97,114,0,2049,2075,4,2049,
130,2049,130,10,20639,20681,168,20615,-3421095308458227740,100,111,117,98,108,101,58,102,101,116,99,
104,0,2049,58,4,15,10,20663,20704,168,20615,-3421095308442276665,100,111,117,98,108,101,58,115,
116,111,114,101,0,1,19,2049,2229,2049,61,16,10,20686,20730,168,20615,-3421095308461432127,100,111,
117,98,108,101,58,99,111,110,115,116,0,2049,20655,1,20681,2049,8433,10,20712,20754,
168,20615,-4575607512064199915,100,111,117,98,108,101,58,115,119,97,112,0,67503109,5,67503109,6,10,
20737,20775,168,20615,8246228896775106679,100,111,117,98,108,101,58,100,105,112,0,67503109,67503109,5,5,
8,6,6,10,20759,20799,168,20615,8246228896775123014,100,111,117,98,108,101,58,115,105,112,0,
1,2217,2049,2229,2049,20775,10,101,120,116,101,110,115,105,111,110,115,47,109,97,
108,108,111,99,46,114,101,116,114,111,0,20783,20846,168,20806,8246632143337714634,109,101,109,58,
105,110,118,111,107,101,0,1,15,2049,10760,2049,10741,10,20830,0,156,20806,210667451248,65,
76,76,79,67,0,20853,1,156,20806,6384048135,70,82,69,69,0,20864,2,156,20806,210689088690,
83,84,79,82,69,0,20874,3,156,20806,210673137615,70,69,84,67,72,0,20885,4,156,
20806,6952683137271,82,69,83,73,90,69,0,20783,20923,168,20806,249897943727936361,109,101,109,58,97,108,
108,111,99,0,1,0,2049,20846,10,20908,20943,168,20806,249897943749573803,109,101,109,58,115,116,
111,114,101,0,1,2,2049,20846,10,20928,20963,168,20806,249897943733622728,109,101,109,58,102,101,
116,99,104,0,1,3,2049,20846,10,20948,20982,168,20806,7572664961638592,109,101,109,58,102,114,
101,101,0,1,1,2049,20846,10,20968,21003,168,20806,8246632143679146032,109,101,109,58,114,101,115,
105,122,101,0,1,4,2049,20846,10,20987,21023,168,20806,249897943730056489,109,101,109,58,99,101,
108,108,43,0,1,8,19,17,10,21008,21050,168,20806,1050530996183190288,109,101,109,58,102,101,
116,99,104,45,100,111,117,98,108,101,0,2,1,1,2049,21023,15,5,2049,20963,
6,10,21028,21083,168,20806,1730340976492540563,109,101,109,58,115,116,111,114,101,45,100,111,117,
98,108,101,0,5,5,2049,2217,1,1,2049,21023,6,2049,20943,6,2049,20943,10,0 };