Changeset 19091 in vbox
- Timestamp:
- Apr 21, 2009 8:57:38 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 46239
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/SysHlp.cpp
r15606 r19091 36 36 int rc = VINF_SUCCESS; 37 37 38 /* Ugly edge case - zero size buffers shouldn't be locked. */ 39 if (u32Size == 0) 40 { 41 *ppvCtx = NIL_RTR0MEMOBJ; 42 return VINF_SUCCESS; 43 } 38 44 #ifdef RT_OS_WINDOWS 39 45 PMDL pMdl = IoAllocateMdl (pv, u32Size, FALSE, FALSE, NULL); … … 68 74 /** @todo r=frank: Linux: pv is at least in some cases, e.g. with VBoxMapFolder, 69 75 * an R0 address -- the memory was allocated with kmalloc(). I don't know 70 * if this is true in any case. */ 76 * if this is true in any case. 77 * r=michael: on Linux, we sometimes have R3 addresses (e.g. shared 78 * clipboard) and sometimes R0 (e.g. shared folders). We really ought 79 * to have two separate paths here - at any rate, Linux R0 shouldn't 80 * end up calling this API. In practice, Linux R3 does it's own thing 81 * before winding up in the R0 path - which calls this stub API. 82 */ 71 83 NOREF(ppvCtx); 72 84 NOREF(pv); … … 92 104 NOREF(u32Size); 93 105 106 /* Ugly edge case - zero size buffers aren't be locked. */ 107 if (pvCtx == NIL_RTR0MEMOBJ) 108 return; 94 109 #ifdef RT_OS_WINDOWS 95 110 PMDL pMdl = (PMDL)pvCtx; -
trunk/src/VBox/Additions/linux/module/vboxmod.c
r18361 r19091 442 442 443 443 AssertPtrReturn(ppBuf, -EINVAL); 444 AssertPtrReturn(pUser, -EINVAL);445 444 446 445 pBuf = RTMemAlloc(sizeof(*pBuf)); … … 449 448 if (rc >= 0) 450 449 { 451 pKernel = RTMemAlloc(cb); 452 if (pKernel == NULL) 453 rc = -ENOMEM; 454 } 455 if ( rc >= 0 456 && copy 457 && copy_from_user(pKernel, pUser, cb) != 0) 458 rc = -EFAULT; 450 if (cb > 0) 451 { 452 pKernel = RTMemAlloc(cb); 453 if (pKernel == NULL) 454 rc = -ENOMEM; 455 if ( rc >= 0 456 && copy 457 && copy_from_user(pKernel, pUser, cb) != 0) 458 rc = -EFAULT; 459 } 460 else 461 /* Empty buffers are allowed, but then the user pointer is not 462 * required to be valid, and we definitely don't want to copy 463 * anything. */ 464 pKernel = NULL; 465 } 459 466 if (rc >= 0) 460 467 { … … 478 485 int rc = 0; 479 486 AssertPtrReturn(pBuf, -EINVAL); 480 if (copy && copy_to_user(pBuf->pUser, pBuf->pKernel, pBuf->cb) != 0) 487 if ((pBuf->cb > 0) 488 && copy 489 && copy_to_user(pBuf->pUser, pBuf->pKernel, pBuf->cb) != 0) 481 490 rc = -EFAULT; 482 491 RTMemFree(pBuf->pKernel); /* We want to do this whatever the outcome. */
Note:
See TracChangeset
for help on using the changeset viewer.