+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2007 Ubiquiti Networks, Inc.
* Copyright (C) 2008 Lukas Kuna <ValXdater@seznam.cz>
* Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <sys/types.h>
} image_info_t;
static image_info_t im;
-static int debug = 0;
static int zero_part_baseaddr = 0;
static void write_header(void* mem, const char* version)
return 0;
}
+#ifndef STRINGIFY
+#define STRINGIFY2(X) #X
+#define STRINGIFY(X) STRINGIFY2(X)
+#endif
static int image_layout_add_partition(const char *part_desc)
{
part_data_t *d;
}
d = &im.parts[im.part_count];
- t = sscanf(part_desc, "%15[a-zA-Z]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%256s",
+ t = sscanf(part_desc, "%15[-0-9a-zA-Z]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%"STRINGIFY(PATH_MAX)"s",
d->partition_name,
offset,
length,
/* write in-memory buffer into file */
if ((f = fopen(im.outputfile, "w")) == NULL) {
ERROR("Can not create output file: '%s'\n", im.outputfile);
+ free(mem);
return -10;
}
if (fwrite(mem, mem_size, 1, f) != 1) {
ERROR("Could not write %d bytes into file: '%s'\n",
mem_size, im.outputfile);
+ free(mem);
+ fclose(f);
return -11;
}