#include <unistd.h>
#include "bup/compat.h"
+#include "bup/intprops.h"
#include "bup/io.h"
static int prog_argc = 0;
return NULL;
PyObject *result = PyList_New(prog_argc);
- for (int i = 0; i < prog_argc; i++) {
+ int i;
+ for (i = 0; i < prog_argc; i++) {
PyObject *s = PyBytes_FromString(prog_argv[i]);
if (!s)
die(2, "cannot convert argument to bytes: %s\n", prog_argv[i]);
len = readlink(PROC_SELF_EXE, path, path_n);
if (len == -1 || (size_t) len != path_n)
break;
+ if (!INT_MULTIPLY_OK(path_n, 2, &path_n))
+ die(2, "memory buffer for executable path would be too big\n");
path_n *= 2;
if (path != sbuf) free(path);
path = malloc(path_n);
int main(int argc, char **argv)
{
+ assert(argc > 0);
prog_argc = argc - 1;
prog_argv = argv + 1;
setup_bup_main_module();