mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-03 06:01:58 +00:00
lxccontainer: fix integer comparisons
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
9a06467860
commit
652a1f4ba5
@ -1625,13 +1625,12 @@ static bool create_run_template(struct lxc_container *c, char *tpath,
|
||||
|
||||
static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
|
||||
{
|
||||
long flen;
|
||||
size_t len;
|
||||
ssize_t len, flen;
|
||||
char *contents;
|
||||
FILE *f;
|
||||
int ret = -1;
|
||||
ssize_t nbytes;
|
||||
#if HAVE_OPENSSL
|
||||
int i;
|
||||
unsigned int md_len = 0;
|
||||
unsigned char md_value[EVP_MAX_MD_SIZE];
|
||||
char *tpath;
|
||||
@ -1709,7 +1708,7 @@ static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
|
||||
|
||||
#if HAVE_OPENSSL
|
||||
fprintf(f, "# Template script checksum (SHA-1): ");
|
||||
for (i=0; i<md_len; i++)
|
||||
for (size_t i = 0; i < md_len; i++)
|
||||
fprintf(f, "%02x", md_value[i]);
|
||||
fprintf(f, "\n");
|
||||
#endif
|
||||
@ -1717,7 +1716,8 @@ static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
|
||||
fprintf(f, "\n# Uncomment the following line to support nesting containers:\n");
|
||||
fprintf(f, "#lxc.include = " LXCTEMPLATECONFIG "/nesting.conf\n");
|
||||
fprintf(f, "# (Be aware this has security implications)\n\n");
|
||||
if (fwrite(contents, 1, flen, f) != flen) {
|
||||
nbytes = fwrite(contents, 1, flen, f);
|
||||
if (nbytes < 0 || nbytes != flen) {
|
||||
SYSERROR("Writing original contents");
|
||||
free(contents);
|
||||
fclose(f);
|
||||
@ -2469,7 +2469,7 @@ static char **do_lxcapi_get_ips(struct lxc_container *c, const char *interface,
|
||||
if (family && !strequal(family, "inet6"))
|
||||
continue;
|
||||
|
||||
if (((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_scope_id != scope)
|
||||
if (((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_scope_id != (uint32_t)scope)
|
||||
continue;
|
||||
|
||||
address_ptr_tmp = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
|
||||
@ -4268,8 +4268,11 @@ static char *get_timestamp(char* snappath, char *name)
|
||||
if (len > 0) {
|
||||
s = malloc(len+1);
|
||||
if (s) {
|
||||
ssize_t nbytes;
|
||||
|
||||
s[len] = '\0';
|
||||
if (fread(s, 1, len, fin) != len)
|
||||
nbytes = fread(s, 1, len, fin);
|
||||
if (nbytes < 0 || nbytes != (ssize_t)len)
|
||||
return log_error_errno(NULL, errno, "reading timestamp");
|
||||
}
|
||||
}
|
||||
@ -5471,13 +5474,13 @@ int list_defined_containers(const char *lxcpath, char ***names,
|
||||
|
||||
free_bad:
|
||||
if (names && *names) {
|
||||
for (int i = 0; i < name_array_len; i++)
|
||||
for (size_t i = 0; i < name_array_len; i++)
|
||||
free((*names)[i]);
|
||||
free(*names);
|
||||
}
|
||||
|
||||
if (cret && *cret) {
|
||||
for (int i = 0; i < ct_array_len; i++)
|
||||
for (size_t i = 0; i < ct_array_len; i++)
|
||||
lxc_container_put((*cret)[i]);
|
||||
free(*cret);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user