geom_disk.c (190878) | geom_disk.c (196823) |
---|---|
1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 20 unchanged lines hidden (view full) --- 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 36#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 20 unchanged lines hidden (view full) --- 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/sys/geom/geom_disk.c 190878 2009-04-10 04:08:34Z thompsa $"); | 37__FBSDID("$FreeBSD: head/sys/geom/geom_disk.c 196823 2009-09-04 09:39:06Z pjd $"); |
38 39#include "opt_geom.h" 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/kernel.h> 44#include <sys/sysctl.h> 45#include <sys/bio.h> 46#include <sys/conf.h> | 38 39#include "opt_geom.h" 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/kernel.h> 44#include <sys/sysctl.h> 45#include <sys/bio.h> 46#include <sys/conf.h> |
47#include <sys/ctype.h> |
|
47#include <sys/fcntl.h> 48#include <sys/malloc.h> 49#include <sys/sysctl.h> 50#include <sys/devicestat.h> 51#include <machine/md_var.h> 52 53#include <sys/lock.h> 54#include <sys/mutex.h> --- 340 unchanged lines hidden (view full) --- 395 if (gp != NULL) { 396 gp->softc = NULL; 397 g_wither_geom(gp, ENXIO); 398 } 399 g_free(dp); 400} 401 402/* | 48#include <sys/fcntl.h> 49#include <sys/malloc.h> 50#include <sys/sysctl.h> 51#include <sys/devicestat.h> 52#include <machine/md_var.h> 53 54#include <sys/lock.h> 55#include <sys/mutex.h> --- 340 unchanged lines hidden (view full) --- 396 if (gp != NULL) { 397 gp->softc = NULL; 398 g_wither_geom(gp, ENXIO); 399 } 400 g_free(dp); 401} 402 403/* |
403 * We only allow [a-zA-Z0-9-_@#%.:] characters, the rest is converted to 'x<HH>'. | 404 * We only allow printable characters in disk ident, 405 * the rest is converted to 'x<HH>'. |
404 */ 405static void 406g_disk_ident_adjust(char *ident, size_t size) 407{ | 406 */ 407static void 408g_disk_ident_adjust(char *ident, size_t size) 409{ |
408 char newid[DISK_IDENT_SIZE], tmp[4]; 409 size_t len; 410 char *p; | 410 char *p, tmp[4], newid[DISK_IDENT_SIZE]; |
411 | 411 |
412 bzero(newid, sizeof(newid)); 413 len = 0; 414 for (p = ident; *p != '\0' && len < sizeof(newid) - 1; p++) { 415 switch (*p) { 416 default: 417 if ((*p < 'a' || *p > 'z') && 418 (*p < 'A' || *p > 'Z') && 419 (*p < '0' || *p > '9')) { 420 snprintf(tmp, sizeof(tmp), "x%02hhx", *p); 421 strlcat(newid, tmp, sizeof(newid)); 422 len += 3; 423 break; 424 } 425 /* FALLTHROUGH */ 426 case '-': 427 case '_': 428 case '@': 429 case '#': 430 case '%': 431 case '.': 432 case ':': 433 newid[len++] = *p; 434 break; | 412 newid[0] = '\0'; 413 for (p = ident; *p != '\0'; p++) { 414 if (isprint(*p)) { 415 tmp[0] = *p; 416 tmp[1] = '\0'; 417 } else { 418 snprintf(tmp, sizeof(tmp), "x%02hhx", 419 *(unsigned char *)p); |
435 } | 420 } |
421 if (strlcat(newid, tmp, sizeof(newid)) >= sizeof(newid)) 422 break; |
|
436 } 437 bzero(ident, size); 438 strlcpy(ident, newid, size); 439} 440 441struct disk * 442disk_alloc() 443{ --- 86 unchanged lines hidden --- | 423 } 424 bzero(ident, size); 425 strlcpy(ident, newid, size); 426} 427 428struct disk * 429disk_alloc() 430{ --- 86 unchanged lines hidden --- |