Lines 48-53
Link Here
|
48 |
#include <unistd.h> |
48 |
#include <unistd.h> |
49 |
#include <ctype.h> |
49 |
#include <ctype.h> |
50 |
#include <stdio.h> |
50 |
#include <stdio.h> |
|
|
51 |
#include <assert.h> |
51 |
|
52 |
|
52 |
#define MB_SHIFT (20) |
53 |
#define MB_SHIFT (20) |
53 |
#define KB_SHIFT (10) |
54 |
#define KB_SHIFT (10) |
Lines 404-414
Link Here
|
404 |
err = stat(src, &st); |
405 |
err = stat(src, &st); |
405 |
|
406 |
|
406 |
if (!err && S_ISREG(st.st_mode)) { |
407 |
if (!err && S_ISREG(st.st_mode)) { |
407 |
char resolved_path[PATH_MAX]; |
408 |
char resolved_path[PATH_MAX-5]; // PATH_MAX - strlen("/host") |
408 |
|
409 |
|
409 |
if (!realpath(src, resolved_path)) |
410 |
if (!realpath(src, resolved_path)) |
410 |
die("Unable to resolve program %s: %s\n", src, strerror(errno)); |
411 |
die("Unable to resolve program %s: %s\n", src, strerror(errno)); |
411 |
|
412 |
|
|
|
413 |
assert(len <= PATH_MAX); |
412 |
snprintf(dst, len, "/host%s", resolved_path); |
414 |
snprintf(dst, len, "/host%s", resolved_path); |
413 |
} else |
415 |
} else |
414 |
strncpy(dst, src, len); |
416 |
strncpy(dst, src, len); |