char *file, *oldfile;
int fd = -1, dirfd = -1;
int modbytes;
+ int r1, r2;
- asprintf(&file, "%s%sldlinux.sys",
- path, path[0] && path[strlen(path) - 1] == '/' ? "" : "/");
- asprintf(&oldfile, "%s%sextlinux.sys",
- path, path[0] && path[strlen(path) - 1] == '/' ? "" : "/");
- if (!file || !oldfile) {
+ r1 = asprintf(&file, "%s%sldlinux.sys",
+ path, path[0] && path[strlen(path) - 1] == '/' ? "" : "/");
+ r2 = asprintf(&oldfile, "%s%sextlinux.sys",
+ path, path[0] && path[strlen(path) - 1] == '/' ? "" : "/");
+ if (r1 < 0 || !file || r2 < 0 || !oldfile) {
perror(program);
return 1;
}
int fd = -1;
struct stat st;
int err = 0;
+ int rv;
- asprintf(&file, "%s%s%s",
- path, path[0] && path[strlen(path) - 1] == '/' ? "" : "/", cfg);
+ rv = asprintf(&file, "%s%s%s", path,
+ path[0] && path[strlen(path) - 1] == '/' ? "" : "/", cfg);
- if (!file) {
+ if (rv < 0 || !file) {
perror(program);
return -1;
}
int fd = -1;
struct stat st, xst;
int err = 0;
+ int rv;
- err = asprintf(&file, "%s%s%s",
- path, path[0] && path[strlen(path) - 1] == '/' ? "" : "/", cfg);
+ rv = asprintf(&file, "%s%s%s", path,
+ path[0] && path[strlen(path) - 1] == '/' ? "" : "/", cfg);
- if (!file) {
+ if (rv < 0 || !file) {
perror(program);
return -1;
}
/* Note: subdir is guaranteed to start and end in / */
if (opt.directory && opt.directory[0]) {
int len = strlen(opt.directory);
- asprintf(&subdir, "%s%s%s",
- opt.directory[0] == '/' ? "" : "/",
- opt.directory,
- opt.directory[len-1] == '/' ? "" : "/");
- if (!subdir) {
+ int rv = asprintf(&subdir, "%s%s%s",
+ opt.directory[0] == '/' ? "" : "/",
+ opt.directory,
+ opt.directory[len-1] == '/' ? "" : "/");
+ if (rv < 0 || !subdir) {
perror(program);
exit(1);
}