mg-dbx 2.4.31 → 2.5.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  High speed Synchronous and Asynchronous access to InterSystems Cache/IRIS and YottaDB from Node.js.
4
4
 
5
5
  Chris Munt <cmunt@mgateway.com>
6
- 9 December 2025, MGateway Ltd [http://www.mgateway.com](http://www.mgateway.com)
6
+ 18 February 2026, MGateway Ltd [http://www.mgateway.com](http://www.mgateway.com)
7
7
 
8
8
  * Verified to work with Node.js v8 to v24.
9
9
  * Two connectivity models to the InterSystems or YottaDB database are provided: High performance via the local database API or network based.
@@ -1243,3 +1243,14 @@ Unless required by applicable law or agreed to in writing, software distributed
1243
1243
  * Correct a potential memory access violation in the **dbx.setloglevel()** method.
1244
1244
  * Correct a potential memory access violation in the **mclass.reset()** method.
1245
1245
 
1246
+ ### v2.5.32 (8 February 2025)
1247
+
1248
+ * Introduce a basic sanity check for M global names. Check that non-printable characters are not included in the name.
1249
+ * Correct a fault in setting extra long string values in M Globals.
1250
+ * The fault occurred for strings longer than 32,767 Bytes (The old default limit for Cache databases).
1251
+ * Newer Cache configurations and IRIS can accept strings of up to 3,641,144 Bytes in length.
1252
+
1253
+ ### v2.5.33 (18 February 2025)
1254
+
1255
+ * Correct a buffer sizing issue affecting Node.js v24 (and later).
1256
+
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Chris Munt <cmunt@mgateway.com> (http://www.gateway.com/)",
3
3
  "name": "mg-dbx",
4
4
  "description": "High speed Synchronous and Asynchronous access to InterSystems Cache/IRIS and YottaDB from Node.js.",
5
- "version": "2.4.31",
5
+ "version": "2.5.33",
6
6
  "maintainers": "Chris Munt <cmunt@mgateway.com>",
7
7
  "homepage": "https://github.com/chrisemunt/mg-dbx",
8
8
  "repository": {
package/src/mg-dbx.cpp CHANGED
@@ -188,6 +188,15 @@ Version 2.4.31 9 December 2025:
188
188
  Correct a potential memory access violation in the dbx.setloglevel() method.
189
189
  Correct a potential memory access violation in the mclass.reset() method.
190
190
 
191
+ Version 2.5.32 8 February 2026:
192
+ Introduce a basic sanity check for M global names. Check that non-printable characters are not included in the name.
193
+ Correct a fault in setting extra long string values in M Globals.
194
+ The fault occurred for strings longer than 32,767 Bytes (The old default limit for Cache databases).
195
+ Newer Cache configurations and IRIS can accept strings of up to 3,641,144 Bytes in length.
196
+
197
+ Version 2.5.33 18 February 2026:
198
+ Correct a buffer sizing issue affecting Node.js v24 (and later).
199
+
191
200
  */
192
201
 
193
202
 
@@ -1464,6 +1473,12 @@ int DBX_DBNAME::GlobalReference(DBX_DBNAME *c, const FunctionCallbackInfo<Value>
1464
1473
  n ++;
1465
1474
  }
1466
1475
 
1476
+ /* v2.5.32
1477
+ rc = pcon->utf16 ? dbx_validate_name(pmeth, (void *) pmeth->args[nx].cvalue.buf16_addr, (int) pmeth->args[nx].cvalue.len_used, pcon->utf16, 0) : dbx_validate_name(pmeth, (void *) pmeth->args[nx].svalue.buf_addr, (int) pmeth->args[nx].svalue.len_used, pcon->utf16, 0);
1478
+ if (rc != CACHE_SUCCESS) {
1479
+ return rc;
1480
+ }
1481
+
1467
1482
  if (pcon->dbtype != DBX_DBTYPE_YOTTADB && context == 0) {
1468
1483
  if (pmeth->lock) {
1469
1484
  rc = pcon->utf16 ? pcon->p_isc_so->p_CachePushLockW((int) pmeth->args[nx].cvalue.len_used, (unsigned short *) pmeth->args[nx].cvalue.buf16_addr) : pcon->p_isc_so->p_CachePushLock((int) pmeth->args[nx].svalue.len_used, (Callin_char_t *) pmeth->args[nx].svalue.buf_addr);
@@ -1483,6 +1498,10 @@ int DBX_DBNAME::GlobalReference(DBX_DBNAME *c, const FunctionCallbackInfo<Value>
1483
1498
  }
1484
1499
  }
1485
1500
  }
1501
+ if (rc != CACHE_SUCCESS) {
1502
+ return rc;
1503
+ }
1504
+ */
1486
1505
 
1487
1506
  nx ++;
1488
1507
  if (pgref && (pval = pgref->pkey)) {
@@ -1511,10 +1530,11 @@ int DBX_DBNAME::GlobalReference(DBX_DBNAME *c, const FunctionCallbackInfo<Value>
1511
1530
  printf("\r\n pval->type=%d; pval->num.int32=%d; pval->svalue.buf_addr=%s", pval->type, pval->num.int32, buffer);
1512
1531
  }
1513
1532
  */
1514
-
1533
+ /* v2.5.32
1515
1534
  if (pcon->dbtype != DBX_DBTYPE_YOTTADB && context == 0) {
1516
1535
  rc = dbx_reference(pmeth, nx);
1517
1536
  }
1537
+ */
1518
1538
  nx ++;
1519
1539
  pval = pval->pnext;
1520
1540
  }
@@ -1555,6 +1575,7 @@ int DBX_DBNAME::GlobalReference(DBX_DBNAME *c, const FunctionCallbackInfo<Value>
1555
1575
  }
1556
1576
  else if (!pcon->utf16 && pmeth->args[nx].svalue.len_used < 32) {
1557
1577
  T_STRNCPY(buffer, _dbxso(buffer), pmeth->args[nx].svalue.buf_addr, pmeth->args[nx].svalue.len_used);
1578
+ buffer[pmeth->args[nx].svalue.len_used] = '\0';
1558
1579
  }
1559
1580
  else {
1560
1581
  buffer[0] = '1';
@@ -1563,11 +1584,10 @@ int DBX_DBNAME::GlobalReference(DBX_DBNAME *c, const FunctionCallbackInfo<Value>
1563
1584
  pmeth->args[nx].type = DBX_DTYPE_DOUBLE;
1564
1585
  pmeth->args[nx].num.real = (double) strtod(buffer, NULL);
1565
1586
  }
1566
-
1587
+ /* v2.5.32
1567
1588
  if (pcon->dbtype != DBX_DBTYPE_YOTTADB && context == 0) {
1568
-
1569
1589
  if (pmeth->lock == 1) {
1570
- if (n < (pmeth->argc - 1)) { /* don't push lock timeout */
1590
+ if (n < (pmeth->argc - 1)) {
1571
1591
  rc = dbx_reference(pmeth, nx);
1572
1592
  }
1573
1593
  }
@@ -1575,10 +1595,56 @@ int DBX_DBNAME::GlobalReference(DBX_DBNAME *c, const FunctionCallbackInfo<Value>
1575
1595
  rc = dbx_reference(pmeth, nx);
1576
1596
  }
1577
1597
  }
1598
+ */
1578
1599
  }
1579
1600
 
1580
1601
  pmeth->cargc = nx;
1581
1602
 
1603
+ /* v2.5.32 */
1604
+ if (pcon->dbtype != DBX_DBTYPE_YOTTADB && context == 0) {
1605
+ rc = dbx_global_reference(pmeth);
1606
+ #if 0
1607
+ nx = 0;
1608
+ rc = pcon->utf16 ? dbx_validate_name(pmeth, (void *) pmeth->args[nx].cvalue.buf16_addr, (int) pmeth->args[nx].cvalue.len_used, pcon->utf16, 0) : dbx_validate_name(pmeth, (void *) pmeth->args[nx].svalue.buf_addr, (int) pmeth->args[nx].svalue.len_used, pcon->utf16, 0);
1609
+ if (rc != CACHE_SUCCESS) {
1610
+ return rc;
1611
+ }
1612
+
1613
+ if (pmeth->lock) {
1614
+ rc = pcon->utf16 ? pcon->p_isc_so->p_CachePushLockW((int) pmeth->args[nx].cvalue.len_used, (unsigned short *) pmeth->args[nx].cvalue.buf16_addr) : pcon->p_isc_so->p_CachePushLock((int) pmeth->args[nx].svalue.len_used, (Callin_char_t *) pmeth->args[nx].svalue.buf_addr);
1615
+ }
1616
+ else {
1617
+ if (pcon->utf16) {
1618
+ if (pmeth->args[nx].cvalue.buf16_addr[0] == 94)
1619
+ rc = pcon->p_isc_so->p_CachePushGlobalW((int) pmeth->args[nx].cvalue.len_used - 1, (unsigned short *) pmeth->args[nx].cvalue.buf16_addr + 1);
1620
+ else
1621
+ rc = pcon->p_isc_so->p_CachePushGlobalW((int) pmeth->args[nx].cvalue.len_used, (unsigned short *) pmeth->args[nx].cvalue.buf16_addr);
1622
+ }
1623
+ else {
1624
+ if (pmeth->args[nx].svalue.buf_addr[0] == '^')
1625
+ rc = pcon->p_isc_so->p_CachePushGlobal((int) pmeth->args[nx].svalue.len_used - 1, (Callin_char_t *) pmeth->args[nx].svalue.buf_addr + 1);
1626
+ else
1627
+ pcon->p_isc_so->p_CachePushGlobal((int) pmeth->args[nx].svalue.len_used, (Callin_char_t *) pmeth->args[nx].svalue.buf_addr);
1628
+ }
1629
+ }
1630
+
1631
+ if (rc != CACHE_SUCCESS) {
1632
+ return rc;
1633
+ }
1634
+
1635
+ for (nx = 1; nx < pmeth->cargc; nx ++) {
1636
+ if (pmeth->lock == 1) {
1637
+ if (nx < (pmeth->cargc - 1)) { /* don't push lock timeout */
1638
+ rc = dbx_reference(pmeth, nx);
1639
+ }
1640
+ }
1641
+ else {
1642
+ rc = dbx_reference(pmeth, nx);
1643
+ }
1644
+ }
1645
+ #endif
1646
+ }
1647
+
1582
1648
  return rc;
1583
1649
  }
1584
1650
 
@@ -1630,6 +1696,7 @@ void DBX_DBNAME::GetEx(const FunctionCallbackInfo<Value>& args, int binary)
1630
1696
  DBX_DBFUN_START(c, pcon, pmeth);
1631
1697
 
1632
1698
  rc = GlobalReference(c, args, pmeth, NULL, (async || pcon->net_connection || pcon->tlevel));
1699
+ DBX_DB_CHECK(rc);
1633
1700
 
1634
1701
  if (pcon->log_transmissions) {
1635
1702
  dbx_log_transmission(pcon, pmeth, (char *) DBX_DBNAME_STR "::get");
@@ -1740,6 +1807,7 @@ void DBX_DBNAME::Set(const FunctionCallbackInfo<Value>& args)
1740
1807
  DBX_DBFUN_START(c, pcon, pmeth);
1741
1808
 
1742
1809
  rc = GlobalReference(c, args, pmeth, NULL, (async || pcon->net_connection || pcon->tlevel));
1810
+ DBX_DB_CHECK(rc);
1743
1811
 
1744
1812
  if (pcon->log_transmissions) {
1745
1813
  dbx_log_transmission(pcon, pmeth, (char *) DBX_DBNAME_STR "::set");
@@ -1837,6 +1905,7 @@ void DBX_DBNAME::Defined(const FunctionCallbackInfo<Value>& args)
1837
1905
  DBX_DBFUN_START(c, pcon, pmeth);
1838
1906
 
1839
1907
  rc = GlobalReference(c, args, pmeth, NULL, (async || pcon->net_connection || pcon->tlevel));
1908
+ DBX_DB_CHECK(rc);
1840
1909
 
1841
1910
  if (pcon->log_transmissions) {
1842
1911
  dbx_log_transmission(pcon, pmeth, (char *) DBX_DBNAME_STR "::defined");
@@ -1935,6 +2004,7 @@ void DBX_DBNAME::Delete(const FunctionCallbackInfo<Value>& args)
1935
2004
  DBX_DBFUN_START(c, pcon, pmeth);
1936
2005
 
1937
2006
  rc = GlobalReference(c, args, pmeth, NULL, (async || pcon->net_connection || pcon->tlevel));
2007
+ DBX_DB_CHECK(rc);
1938
2008
 
1939
2009
  if (pcon->log_transmissions) {
1940
2010
  dbx_log_transmission(pcon, pmeth, (char *) DBX_DBNAME_STR "::delete");
@@ -2032,6 +2102,7 @@ void DBX_DBNAME::Next(const FunctionCallbackInfo<Value>& args)
2032
2102
  DBX_DBFUN_START(c, pcon, pmeth);
2033
2103
 
2034
2104
  rc = GlobalReference(c, args, pmeth, NULL, (async || pcon->net_connection || pcon->tlevel));
2105
+ DBX_DB_CHECK(rc);
2035
2106
 
2036
2107
  if (pcon->log_transmissions) {
2037
2108
  dbx_log_transmission(pcon, pmeth, (char *) DBX_DBNAME_STR "::next");
@@ -2128,6 +2199,7 @@ void DBX_DBNAME::Previous(const FunctionCallbackInfo<Value>& args)
2128
2199
  DBX_DBFUN_START(c, pcon, pmeth);
2129
2200
 
2130
2201
  rc = GlobalReference(c, args, pmeth, NULL, (async || pcon->net_connection || pcon->tlevel));
2202
+ DBX_DB_CHECK(rc);
2131
2203
 
2132
2204
  if (pcon->log_transmissions) {
2133
2205
  dbx_log_transmission(pcon, pmeth, (char *) DBX_DBNAME_STR "::previous");
@@ -2226,6 +2298,7 @@ void DBX_DBNAME::Increment(const FunctionCallbackInfo<Value>& args)
2226
2298
 
2227
2299
  pmeth->increment = 1;
2228
2300
  rc = GlobalReference(c, args, pmeth, NULL, (async || pcon->net_connection || pcon->tlevel));
2301
+ DBX_DB_CHECK(rc);
2229
2302
 
2230
2303
  if (pcon->log_transmissions) {
2231
2304
  dbx_log_transmission(pcon, pmeth, (char *) DBX_DBNAME_STR "::increment");
@@ -2325,6 +2398,7 @@ void DBX_DBNAME::Lock(const FunctionCallbackInfo<Value>& args)
2325
2398
 
2326
2399
  pmeth->lock = 1;
2327
2400
  rc = GlobalReference(c, args, pmeth, NULL, (async || pcon->net_connection || pcon->tlevel));
2401
+ DBX_DB_CHECK(rc);
2328
2402
 
2329
2403
  if (pcon->log_transmissions) {
2330
2404
  dbx_log_transmission(pcon, pmeth, (char *) DBX_DBNAME_STR "::lock");
@@ -2449,6 +2523,7 @@ void DBX_DBNAME::Unlock(const FunctionCallbackInfo<Value>& args)
2449
2523
 
2450
2524
  pmeth->lock = 2;
2451
2525
  rc = GlobalReference(c, args, pmeth, NULL, (async || pcon->net_connection || pcon->tlevel));
2526
+ DBX_DB_CHECK(rc);
2452
2527
 
2453
2528
  if (pcon->log_transmissions) {
2454
2529
  dbx_log_transmission(pcon, pmeth, (char *) DBX_DBNAME_STR "::unlock");
@@ -4258,7 +4333,8 @@ __try {
4258
4333
  str = DBX_TO_STRING(args[argc_offset]);
4259
4334
  global_name16_len = 0;
4260
4335
  global_name_len = dbx_string8_length(isolate, str, pcon->utf8);
4261
- dbx_write_char8(isolate, str, global_name, 256, pcon->utf8);
4336
+ dbx_write_char8(isolate, str, global_name, 266, pcon->utf8);
4337
+
4262
4338
  if (global_name_len == 0) {
4263
4339
  return -1;
4264
4340
  }
@@ -4347,8 +4423,8 @@ __try {
4347
4423
  pval->cvalue.buf16_addr = (unsigned short *) dbx_malloc(sizeof(unsigned short) * (len + 32), 0);
4348
4424
  pval->type = DBX_DTYPE_STR16;
4349
4425
  pval->svalue.buf_addr = NULL;
4426
+ pval->cvalue.len_alloc = len + 32; /* v2.5.33 */
4350
4427
  dbx_write_char16(isolate, str, pval->cvalue.buf16_addr);
4351
- pval->cvalue.len_alloc = len + 32;
4352
4428
  pval->cvalue.len_used = len;
4353
4429
  }
4354
4430
  else {
@@ -4357,8 +4433,8 @@ __try {
4357
4433
  pval->cvalue.buf16_addr = NULL;
4358
4434
  pval->type = DBX_DTYPE_STR;
4359
4435
  pval->svalue.buf_addr = ((char *) pval) + sizeof(DBXVAL);
4436
+ pval->svalue.len_alloc = len + 32; /* v2.5.33 */
4360
4437
  dbx_write_char8(isolate, str, pval->svalue.buf_addr, pval->svalue.len_alloc, 1);
4361
- pval->svalue.len_alloc = len + 32;
4362
4438
  pval->svalue.len_used = len;
4363
4439
  }
4364
4440
  }
@@ -7286,7 +7362,6 @@ __try {
7286
7362
  if (pcon->p_isc_so && no_connections == 0 && pcon->p_isc_so->multiple_connections == 0) { /* v2.0.16 */
7287
7363
 
7288
7364
  if (pcon->p_isc_so->loaded) {
7289
- /* pcon->p_isc_so->p_CacheEnd(); */
7290
7365
  pcon->p_isc_so->p_CacheEnd();
7291
7366
  dbx_dso_unload(pcon->p_isc_so->p_library);
7292
7367
  pcon->p_isc_so->p_library = NULL;
@@ -7530,25 +7605,32 @@ __try {
7530
7605
  for (n = 0; n < pmeth->cargc; n ++) {
7531
7606
 
7532
7607
  if (n == 0) {
7533
- if (pcon->dbtype != DBX_DBTYPE_YOTTADB) {
7534
- if (pmeth->lock) {
7535
- rc = pcon->utf16 ? pcon->p_isc_so->p_CachePushLockW((int) pmeth->args[n].cvalue.len_used, (unsigned short *) pmeth->args[n].cvalue.buf16_addr) : pcon->p_isc_so->p_CachePushLock((int) pmeth->args[n].svalue.len_used, (Callin_char_t *) pmeth->args[n].svalue.buf_addr);
7608
+
7609
+ /* v2.5.32 */
7610
+ rc = pcon->utf16 ? dbx_validate_name(pmeth, (void *) pmeth->args[n].cvalue.buf16_addr, (int) pmeth->args[n].cvalue.len_used, pcon->utf16, 0) : dbx_validate_name(pmeth, (void *) pmeth->args[n].svalue.buf_addr, (int) pmeth->args[n].svalue.len_used, pcon->utf16, 0);
7611
+ if (rc != CACHE_SUCCESS) {
7612
+ break;
7613
+ }
7614
+ if (pmeth->lock) {
7615
+ rc = pcon->utf16 ? pcon->p_isc_so->p_CachePushLockW((int) pmeth->args[n].cvalue.len_used, (unsigned short *) pmeth->args[n].cvalue.buf16_addr) : pcon->p_isc_so->p_CachePushLock((int) pmeth->args[n].svalue.len_used, (Callin_char_t *) pmeth->args[n].svalue.buf_addr);
7616
+ }
7617
+ else {
7618
+ if (pcon->utf16) {
7619
+ if (pmeth->args[n].cvalue.buf16_addr[0] == 94)
7620
+ rc = pcon->p_isc_so->p_CachePushGlobalW((int) pmeth->args[n].cvalue.len_used - 1, (unsigned short *) pmeth->args[n].cvalue.buf16_addr + 1);
7621
+ else
7622
+ rc = pcon->p_isc_so->p_CachePushGlobalW((int) pmeth->args[n].cvalue.len_used, (unsigned short *) pmeth->args[n].cvalue.buf16_addr);
7536
7623
  }
7537
7624
  else {
7538
- if (pcon->utf16) {
7539
- if (pmeth->args[n].cvalue.buf16_addr[0] == 94)
7540
- rc = pcon->p_isc_so->p_CachePushGlobalW((int) pmeth->args[n].cvalue.len_used - 1, (unsigned short *) pmeth->args[n].cvalue.buf16_addr + 1);
7541
- else
7542
- rc = pcon->p_isc_so->p_CachePushGlobalW((int) pmeth->args[n].cvalue.len_used, (unsigned short *) pmeth->args[n].cvalue.buf16_addr);
7543
- }
7544
- else {
7545
- if (pmeth->args[n].svalue.buf_addr[0] == '^')
7546
- rc = pcon->p_isc_so->p_CachePushGlobal((int) pmeth->args[n].svalue.len_used - 1, (Callin_char_t *) pmeth->args[n].svalue.buf_addr + 1);
7547
- else
7548
- pcon->p_isc_so->p_CachePushGlobal((int) pmeth->args[n].svalue.len_used, (Callin_char_t *) pmeth->args[n].svalue.buf_addr);
7549
- }
7625
+ if (pmeth->args[n].svalue.buf_addr[0] == '^')
7626
+ rc = pcon->p_isc_so->p_CachePushGlobal((int) pmeth->args[n].svalue.len_used - 1, (Callin_char_t *) pmeth->args[n].svalue.buf_addr + 1);
7627
+ else
7628
+ rc = pcon->p_isc_so->p_CachePushGlobal((int) pmeth->args[n].svalue.len_used, (Callin_char_t *) pmeth->args[n].svalue.buf_addr);
7550
7629
  }
7551
7630
  }
7631
+ if (rc != CACHE_SUCCESS) {
7632
+ break;
7633
+ }
7552
7634
  continue;
7553
7635
  }
7554
7636
 
@@ -7560,6 +7642,9 @@ __try {
7560
7642
  else {
7561
7643
  rc = dbx_reference(pmeth, n);
7562
7644
  }
7645
+ if (rc != CACHE_SUCCESS) {
7646
+ break;
7647
+ }
7563
7648
  }
7564
7649
  return rc;
7565
7650
 
@@ -7602,7 +7687,6 @@ __try {
7602
7687
  }
7603
7688
 
7604
7689
  rc = dbx_global_reference(pmeth);
7605
-
7606
7690
  if (rc != CACHE_SUCCESS) {
7607
7691
  dbx_error_message(pmeth, rc);
7608
7692
  goto dbx_get_exit;
@@ -7671,7 +7755,6 @@ __try {
7671
7755
  }
7672
7756
 
7673
7757
  rc = dbx_global_reference(pmeth);
7674
-
7675
7758
  if (rc != CACHE_SUCCESS) {
7676
7759
  dbx_error_message(pmeth, rc);
7677
7760
  goto dbx_set_exit;
@@ -8248,6 +8331,8 @@ int dbx_merge(DBXMETH *pmeth)
8248
8331
  __try {
8249
8332
  #endif
8250
8333
 
8334
+ rc = CACHE_SUCCESS;
8335
+
8251
8336
  DBX_DB_LOCK(0);
8252
8337
 
8253
8338
  if (pcon->net_connection) {
@@ -10634,6 +10719,69 @@ __except (EXCEPTION_EXECUTE_HANDLER) {
10634
10719
  }
10635
10720
 
10636
10721
 
10722
+ /* v2.5.32 */
10723
+ int dbx_validate_name(DBXMETH *pmeth, void * pbuffer, int buffer_len, short char16, short context)
10724
+ {
10725
+ int rc, n;
10726
+ unsigned char c, *p, *pz;
10727
+
10728
+ rc = CACHE_SUCCESS;
10729
+ if (char16) { /* TODO */
10730
+ return rc;
10731
+ }
10732
+
10733
+ p = (unsigned char *) pbuffer;
10734
+ pz = (unsigned char *) ((unsigned char *) pbuffer + buffer_len);
10735
+ n = 0;
10736
+
10737
+ if (strstr((char *) p, "[")) {
10738
+ p = (unsigned char *) strstr((char *) p, "]");
10739
+ if (!p) {
10740
+ /* printf("dbx_validate_name: Invalid extended reference"); */
10741
+ return CACHE_BAD_GLOBAL;
10742
+ }
10743
+ }
10744
+ if (*p == '^') {
10745
+ p ++;
10746
+ }
10747
+
10748
+ c = (int) *p;
10749
+ if (!((c == 37) || dbx_isalpha((int) c))) {
10750
+ /* printf("dbx_validate_name: Invalid name - must begin with an alphabetic or '%%' (%d:%c)", (int) c, (char) c); */
10751
+ return CACHE_BAD_GLOBAL;
10752
+ }
10753
+ else {
10754
+ p ++;
10755
+ }
10756
+ c = (int) *(pz - 1);
10757
+ if (!(isdigit((int) c) || dbx_isalpha((int) c))) {
10758
+ /* printf("dbx_validate_name: Invalid name - must end with an alphanumeric (%d:%c)", (int) c, (char) c); */
10759
+ return CACHE_BAD_GLOBAL;
10760
+ }
10761
+
10762
+ /* Just test for control characters for now */
10763
+ while (p < pz) {
10764
+ c = (int) *p;
10765
+ if (((int) c) < 32) {
10766
+ /* printf("dbx_validate_name: Invalid name - must contain alphanumerics or '.' (%d:%c)", (int) c, (char) c); */
10767
+ rc = CACHE_BAD_GLOBAL;
10768
+ break;
10769
+ }
10770
+ p ++;
10771
+ }
10772
+ /*
10773
+ while (p < pz) {
10774
+ c = (int) *p;
10775
+ if (!((*p == '.') || isdigit((int) c) || dbx_isalpha((int) c))) {
10776
+ printf("dbx_validate_name: Invalid name - must contain alphanumerics or '.' (%d:%c)", (int) c, (char) c);
10777
+ rc = CACHE_BAD_GLOBAL;
10778
+ break;
10779
+ }
10780
+ p ++;
10781
+ }
10782
+ */
10783
+ return rc;
10784
+ }
10637
10785
 
10638
10786
  int cache_report_failure(DBXCON *pcon)
10639
10787
  {
@@ -11161,6 +11309,24 @@ int dbx_lcase(char *string)
11161
11309
  #endif
11162
11310
  }
11163
11311
 
11312
+ /* v2.5.32 */
11313
+ int dbx_isalpha(int c)
11314
+ {
11315
+ if (isalpha(c))
11316
+ return 1;
11317
+ else if (c == 170)
11318
+ return 1;
11319
+ else if (c == 181)
11320
+ return 1;
11321
+ else if (c == 186)
11322
+ return 1;
11323
+ else if (c >= 192 && c <= 255)
11324
+ return 1;
11325
+ else
11326
+ return 0;
11327
+ return 0;
11328
+ }
11329
+
11164
11330
 
11165
11331
  int dbx_create_string(DBXSTR *pstr, void *data, short type)
11166
11332
  {
package/src/mg-dbx.h CHANGED
@@ -32,8 +32,8 @@
32
32
  #define DBX_NODE_VERSION (NODE_MAJOR_VERSION * 10000) + (NODE_MINOR_VERSION * 100) + NODE_PATCH_VERSION
33
33
 
34
34
  #define DBX_VERSION_MAJOR "2"
35
- #define DBX_VERSION_MINOR "4"
36
- #define DBX_VERSION_BUILD "31"
35
+ #define DBX_VERSION_MINOR "5"
36
+ #define DBX_VERSION_BUILD "33"
37
37
 
38
38
  #define DBX_VERSION DBX_VERSION_MAJOR "." DBX_VERSION_MINOR "." DBX_VERSION_BUILD
39
39
 
@@ -702,6 +702,17 @@ typedef struct {
702
702
  #define YDB_TPCTX_QUERY 11
703
703
  #define YDB_TPCTX_ORDER 12
704
704
 
705
+ /* v2.5.32 */
706
+
707
+ #define DBX_DB_CHECK(RC) \
708
+ if (RC != CACHE_SUCCESS) { \
709
+ isolate->ThrowException(Exception::Error(dbx_new_string8(isolate, (char *) "Invalid global name", 1))); \
710
+ DBX_DBFUN_END(c); \
711
+ DBX_DB_UNLOCK(); \
712
+ dbx_request_memory_free(pcon, pmeth, 0); \
713
+ return; \
714
+ } \
715
+
705
716
  typedef struct {
706
717
  unsigned int len_alloc;
707
718
  unsigned int len_used;
@@ -1285,6 +1296,7 @@ int dbx_global_order (DBXMETH *pmeth, DBXQR
1285
1296
  int dbx_global_query (DBXMETH *pmeth, DBXQR *pqr_next, DBXQR *pqr_prev, short dir, short getdata);
1286
1297
  int dbx_parse_global_reference (DBXMETH *pmeth, DBXQR *pqr, char *global_ref, int global_ref_len);
1287
1298
  int dbx_parse_global_reference16 (DBXMETH *pmeth, DBXQR *pqr, unsigned short *global_ref, int global_ref_len);
1299
+ int dbx_validate_name (DBXMETH *pmeth, void * pbuffer, int buffer_len, short char16, short context);
1288
1300
 
1289
1301
  int dbx_launch_thread (DBXMETH *pmeth);
1290
1302
  #if defined(_WIN32)
@@ -1310,6 +1322,7 @@ DBXQR * dbx_alloc_dbxqr (DBXQR *pqr, int dsize,
1310
1322
  int dbx_free_dbxqr (DBXQR *pqr);
1311
1323
  int dbx_ucase (char *string);
1312
1324
  int dbx_lcase (char *string);
1325
+ int dbx_isalpha (int c);
1313
1326
 
1314
1327
  int dbx_create_string (DBXSTR *pstr, void *data, short type);
1315
1328
 
package/src/mg-global.cpp CHANGED
@@ -274,6 +274,7 @@ void mglobal::GetEx(const FunctionCallbackInfo<Value>& args, int binary)
274
274
  DBX_DBFUN_START(c, pcon, pmeth);
275
275
 
276
276
  rc = c->GlobalReference(c, args, pmeth, &gref, (async || pcon->net_connection || pcon->tlevel));
277
+ DBX_DB_CHECK(rc);
277
278
 
278
279
  if (pcon->log_transmissions) {
279
280
  dbx_log_transmission(pcon, pmeth, (char *) "mglobal::get");
@@ -385,6 +386,7 @@ void mglobal::Set(const FunctionCallbackInfo<Value>& args)
385
386
  DBX_DBFUN_START(c, pcon, pmeth);
386
387
 
387
388
  rc = c->GlobalReference(c, args, pmeth, &gref, (async || pcon->net_connection || pcon->tlevel));
389
+ DBX_DB_CHECK(rc);
388
390
 
389
391
  if (pcon->log_transmissions) {
390
392
  dbx_log_transmission(pcon, pmeth, (char *) "mglobal::set");
@@ -489,6 +491,7 @@ void mglobal::Defined(const FunctionCallbackInfo<Value>& args)
489
491
  DBX_DBFUN_START(c, pcon, pmeth);
490
492
 
491
493
  rc = c->GlobalReference(c, args, pmeth, &gref, (async || pcon->net_connection || pcon->tlevel));
494
+ DBX_DB_CHECK(rc);
492
495
 
493
496
  if (pcon->log_transmissions) {
494
497
  dbx_log_transmission(pcon, pmeth, (char *) "mglobal::defined");
@@ -592,6 +595,7 @@ void mglobal::Delete(const FunctionCallbackInfo<Value>& args)
592
595
  DBX_DBFUN_START(c, pcon, pmeth);
593
596
 
594
597
  rc = c->GlobalReference(c, args, pmeth, &gref, (async || pcon->net_connection || pcon->tlevel));
598
+ DBX_DB_CHECK(rc);
595
599
 
596
600
  if (pcon->log_transmissions) {
597
601
  dbx_log_transmission(pcon, pmeth, (char *) "mglobal::delete");
@@ -695,6 +699,7 @@ void mglobal::Next(const FunctionCallbackInfo<Value>& args)
695
699
  DBX_DBFUN_START(c, pcon, pmeth);
696
700
 
697
701
  rc = c->GlobalReference(c, args, pmeth, &gref, (async || pcon->net_connection || pcon->tlevel));
702
+ DBX_DB_CHECK(rc);
698
703
 
699
704
  if (pcon->log_transmissions) {
700
705
  dbx_log_transmission(pcon, pmeth, (char *) "mglobal::next");
@@ -797,6 +802,7 @@ void mglobal::Previous(const FunctionCallbackInfo<Value>& args)
797
802
  DBX_DBFUN_START(c, pcon, pmeth);
798
803
 
799
804
  rc = c->GlobalReference(c, args, pmeth, &gref, (async || pcon->net_connection || pcon->tlevel));
805
+ DBX_DB_CHECK(rc);
800
806
 
801
807
  if (pcon->log_transmissions) {
802
808
  dbx_log_transmission(pcon, pmeth, (char *) "mglobal::previous");
@@ -900,6 +906,7 @@ void mglobal::Increment(const FunctionCallbackInfo<Value>& args)
900
906
 
901
907
  pmeth->increment = 1;
902
908
  rc = c->GlobalReference(c, args, pmeth, &gref, (async || pcon->net_connection || pcon->tlevel));
909
+ DBX_DB_CHECK(rc);
903
910
 
904
911
  if (pcon->log_transmissions) {
905
912
  dbx_log_transmission(pcon, pmeth, (char *) "mglobal::increment");
@@ -1009,6 +1016,7 @@ void mglobal::Lock(const FunctionCallbackInfo<Value>& args)
1009
1016
 
1010
1017
  pmeth->lock = 1;
1011
1018
  rc = c->GlobalReference(c, args, pmeth, &gref, (async || pcon->net_connection || pcon->tlevel));
1019
+ DBX_DB_CHECK(rc);
1012
1020
 
1013
1021
  if (pcon->log_transmissions) {
1014
1022
  dbx_log_transmission(pcon, pmeth, (char *) "mglobal::lock");
@@ -1138,6 +1146,7 @@ void mglobal::Unlock(const FunctionCallbackInfo<Value>& args)
1138
1146
 
1139
1147
  pmeth->lock = 2;
1140
1148
  rc = c->GlobalReference(c, args, pmeth, &gref, (async || pcon->net_connection || pcon->tlevel));
1149
+ DBX_DB_CHECK(rc);
1141
1150
 
1142
1151
  if (pcon->log_transmissions) {
1143
1152
  dbx_log_transmission(pcon, pmeth, (char *) "mglobal::unlock");