MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dump_check_bounds

Function dump_check_bounds

freebsd/kern/kern_shutdown.c:1359–1389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1357}
1358
1359static int
1360dump_check_bounds(struct dumperinfo *di, off_t offset, size_t length)
1361{
1362
1363 if (di->mediasize > 0 && length != 0 && (offset < di->mediaoffset ||
1364 offset - di->mediaoffset + length > di->mediasize)) {
1365 if (di->kdcomp != NULL && offset >= di->mediaoffset) {
1366 printf(
1367 "Compressed dump failed to fit in device boundaries.\n");
1368 return (E2BIG);
1369 }
1370
1371 printf("Attempt to write outside dump device boundaries.\n"
1372 "offset(%jd), mediaoffset(%jd), length(%ju), mediasize(%jd).\n",
1373 (intmax_t)offset, (intmax_t)di->mediaoffset,
1374 (uintmax_t)length, (intmax_t)di->mediasize);
1375 return (ENOSPC);
1376 }
1377 if (length % di->blocksize != 0) {
1378 printf("Attempt to write partial block of length %ju.\n",
1379 (uintmax_t)length);
1380 return (EINVAL);
1381 }
1382 if (offset % di->blocksize != 0) {
1383 printf("Attempt to write at unaligned offset %jd.\n",
1384 (intmax_t)offset);
1385 return (EINVAL);
1386 }
1387
1388 return (0);
1389}
1390
1391#ifdef EKCD
1392static int

Callers 1

dump_writeFunction · 0.85

Calls 1

printfFunction · 0.70

Tested by

no test coverage detected