Changeset 100772 in vbox for trunk/src/VBox/HostDrivers/VBoxUSB
- Timestamp:
- Aug 1, 2023 5:34:48 PM (22 months ago)
- svn:sync-xref-src-repo-rev:
- 158650
- Location:
- trunk/src/VBox/HostDrivers/VBoxUSB
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/USBFilter.cpp
r98103 r100772 226 226 227 227 /* 228 * The string format is: " (<m>|([<m>]-[<n>]))|(<m>|([<m>]-[<n>]))+"229 * where <m> and <n> are numbers in the decimal, hex (0xNNN) or octal (0NNN)230 * form.Spaces are allowed around <m> and <n>.228 * The string format is: "int:((<m>)|([<m>]-[<n>]))(,(<m>)|([<m>]-[<n>]))*" 229 * where <m> and <n> are numbers in decimal, hex (0xNNN) or octal (0NNN). 230 * Spaces are allowed around <m> and <n>. 231 231 */ 232 232 unsigned cSubExpressions = 0; 233 233 while (*pszExpr) 234 234 { 235 if (!strncmp(pszExpr, RT_STR_TUPLE("int:"))) 236 pszExpr += strlen("int:"); 237 235 238 /* 236 239 * Skip remnants of the previous expression and any empty expressions. 237 240 * ('|' is the expression separator.) 238 241 */ 239 while (*pszExpr == '|' || RT_C_IS_BLANK(*pszExpr) )242 while (*pszExpr == '|' || RT_C_IS_BLANK(*pszExpr) || *pszExpr == '(' || *pszExpr == ')') 240 243 pszExpr++; 241 244 if (!*pszExpr) … … 256 259 else 257 260 { 258 /* M or M -N*/261 /* M or M,N or M-N or M- */ 259 262 rc = usbfilterReadNumber(&pszExpr, &u16First); 260 263 if (RT_SUCCESS(rc)) 261 264 { 265 pszExpr = usbfilterSkipBlanks(pszExpr); 262 266 if (*pszExpr == '-') 263 267 { 264 /* M-N */ 268 pszExpr++; 269 if (*pszExpr) /* M-N */ 270 rc = usbfilterReadNumber(&pszExpr, &u16Last); 271 else /* M- */ 272 u16Last = UINT16_MAX; 273 } 274 else if (*pszExpr == ',') 275 { 276 /* M,N */ 265 277 pszExpr++; 266 278 rc = usbfilterReadNumber(&pszExpr, &u16Last); … … 277 289 278 290 /* 279 * We should either be at the end of the string or at280 * an expression separator (|).291 * We should either be at the end of the string, at an expression separator (|), 292 * or at the end of an interval filter (')'). 281 293 */ 282 if (*pszExpr && *pszExpr != '|' )294 if (*pszExpr && *pszExpr != '|' && *pszExpr != ')') 283 295 return VERR_INVALID_PARAMETER; 284 296 … … 590 602 { 591 603 /* 592 * The string format is: " (<m>|([<m>]-[<n>]))|(<m>|([<m>]-[<n>]))+"593 * where <m> and <n> are numbers in the decimal, hex (0xNNN) or octal (0NNN)594 * form.Spaces are allowed around <m> and <n>.604 * The string format is: "int:((<m>)|([<m>]-[<n>]))(,(<m>)|([<m>]-[<n>]))*" 605 * where <m> and <n> are numbers in decimal, hex (0xNNN) or octal (0NNN). 606 * Spaces are allowed around <m> and <n>. 595 607 */ 596 608 while (*pszExpr) 597 609 { 610 if (!strncmp(pszExpr, RT_STR_TUPLE("int:"))) 611 pszExpr += strlen("int:"); 612 598 613 /* 599 614 * Skip remnants of the previous expression and any empty expressions. 600 615 * ('|' is the expression separator.) 601 616 */ 602 while (*pszExpr == '|' || RT_C_IS_BLANK(*pszExpr) )617 while (*pszExpr == '|' || RT_C_IS_BLANK(*pszExpr) || *pszExpr == '(' || *pszExpr == ')') 603 618 pszExpr++; 604 619 if (!*pszExpr) … … 619 634 else 620 635 { 621 /* M or M -N*/636 /* M or M,N or M-N or M- */ 622 637 rc = usbfilterReadNumber(&pszExpr, &u16First); 623 638 if (RT_SUCCESS(rc)) … … 626 641 if (*pszExpr == '-') 627 642 { 628 /* M-N */ 643 pszExpr++; 644 if (*pszExpr) /* M-N */ 645 rc = usbfilterReadNumber(&pszExpr, &u16Last); 646 else /* M- */ 647 u16Last = UINT16_MAX; 648 } 649 else if (*pszExpr == ',') 650 { 651 /* M,N */ 629 652 pszExpr++; 630 653 rc = usbfilterReadNumber(&pszExpr, &u16Last); … … 638 661 } 639 662 640 /* On success, we should either be at the end of the string or 641 at an expression separator (|). */ 642 if (RT_SUCCESS(rc) && *pszExpr && *pszExpr != '|' ) 663 /* On success, we should either be at the end of the string, at an expression 664 * separator (|), or at the end of an interval filter (')'). 665 */ 666 if (RT_SUCCESS(rc) && *pszExpr && *pszExpr != '|' && *pszExpr != ')') 643 667 rc = VERR_INVALID_PARAMETER; 644 668 if (RT_SUCCESS(rc)) -
trunk/src/VBox/HostDrivers/VBoxUSB/testcase/tstUSBFilter.cpp
r98103 r100772 286 286 TST_CHECK_EXPR(!USBFilterMatch(&Flt1, &Dev)); 287 287 288 /* numeric patterns - interval filters */ 289 TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "int:0x0-0xffff", true)); 290 TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev)); 291 TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "int: 0x0 - 0xffff ", true)); 292 TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev)); 293 TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_PRODUCT_ID, "int:0x0028-", true)); 294 TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev)); 295 TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_DEVICE_REV, "int:-0x0045", true)); 296 TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev)); 297 TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_PORT, "int:1,4", true)); 298 TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev)); 299 TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_PORT, "int:( 1, 3 )", true)); 300 TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev)); 301 288 302 TST_CHECK_RC(USBFilterSetNumExpression(&Flt1, USBFILTERIDX_VENDOR_ID, "39-59|0x256-0x101f|0xfffff-0xf000|0x1000-0x2000", true)); 289 303 TST_CHECK_EXPR(USBFilterMatch(&Flt1, &Dev));
Note:
See TracChangeset
for help on using the changeset viewer.