Stricter flexelinting

parent 88d42892
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
-esym(844, vmod_priv_blob*, VGC_*) -esym(844, vmod_priv_blob*, VGC_*)
-esym(768, arg_vmod_blob*) -esym(768, arg_vmod_blob*)
-emacro(774, REPLACE) // 'if' always evaluates to False -emacro(774, REPLACE) // 'if' always evaluates to False
-emacro(747, ALLOC_OBJ)
-efunc(663, tus_obj*, tus_body_assign) // suspicious array oc->stobj
// not fully understood // not fully understood
-efunc(413, *_VSPLAY_NEXT) -efunc(413, *_VSPLAY_NEXT)
......
...@@ -101,11 +101,11 @@ tus_file_final_concat_parse(const char *spec) ...@@ -101,11 +101,11 @@ tus_file_final_concat_parse(const char *spec)
if (p == NULL) if (p == NULL)
p = strchr(spec, '\0'); p = strchr(spec, '\0');
AN(p); AN(p);
VSB_bcat(vsb, spec, p - spec); AZ(VSB_bcat(vsb, spec, p - spec));
VSB_bcat(vsb, "\0", 1); AZ(VSB_putc(vsb, '\0'));
spec = strchr(spec, ' '); spec = strchr(spec, ' ');
} }
VSB_bcat(vsb, "\0", 1); AZ(VSB_putc(vsb, '\0'));
AZ(VSB_finish(vsb)); AZ(VSB_finish(vsb));
return (vsb); return (vsb);
...@@ -168,7 +168,7 @@ tus_file_final_concat(struct VPFX(tus_server) *srv, ...@@ -168,7 +168,7 @@ tus_file_final_concat(struct VPFX(tus_server) *srv,
errno = EINTR; errno = EINTR;
while (part->ptr == NULL && errno == EINTR) { while (part->ptr == NULL && errno == EINTR) {
errno = Lck_CondWaitTimeout(&part->cond, errno = Lck_CondWaitTimeout(&part->cond,
&part->mtx, READY_TIMEOUT); &part->mtx, (vtim_dur)READY_TIMEOUT);
} }
Lck_Unlock(&part->mtx); Lck_Unlock(&part->mtx);
if (part->ptr == NULL) if (part->ptr == NULL)
...@@ -211,6 +211,7 @@ tus_file_final_birth(struct tus_file_core **fcorep, ...@@ -211,6 +211,7 @@ tus_file_final_birth(struct tus_file_core **fcorep,
struct tus_file_core *fcore; struct tus_file_core *fcore;
struct tus_file_disk *fdisk; struct tus_file_disk *fdisk;
struct vsb *vsb; struct vsb *vsb;
ssize_t l;
TAKE_OBJ_NOTNULL(fcore, fcorep, VMOD_TUS_FILE_CORE_MAGIC); TAKE_OBJ_NOTNULL(fcore, fcorep, VMOD_TUS_FILE_CORE_MAGIC);
Lck_AssertHeld(&fcore->mtx); Lck_AssertHeld(&fcore->mtx);
...@@ -228,7 +229,9 @@ tus_file_final_birth(struct tus_file_core **fcorep, ...@@ -228,7 +229,9 @@ tus_file_final_birth(struct tus_file_core **fcorep,
vsb = embryo->spec_vsb; vsb = embryo->spec_vsb;
assert(fcore->fd >= 0); assert(fcore->fd >= 0);
if (write(fcore->fd, VSB_data(vsb), VSB_len(vsb)) < 0) l = VSB_len(vsb);
assert(l >= 0);
if (write(fcore->fd, VSB_data(vsb), (size_t)l) < 0)
tus_file_del(&fcore); tus_file_del(&fcore);
VSB_destroy(&vsb); VSB_destroy(&vsb);
memset(embryo, 0, sizeof *embryo); memset(embryo, 0, sizeof *embryo);
...@@ -325,7 +328,12 @@ tus_file_final_urls(VRT_CTX, const struct tus_file_core *fcore, const char *pfx) ...@@ -325,7 +328,12 @@ tus_file_final_urls(VRT_CTX, const struct tus_file_core *fcore, const char *pfx)
return (NULL); return (NULL);
WS_VSB_new(vsb, ctx->ws); WS_VSB_new(vsb, ctx->ws);
VSB_cat(vsb, "final;");
/*
* ignoring VSB_*() returns because ws can overflow
* the error is returned by WS_VSB_finish
*/
(void)VSB_cat(vsb, "final;");
assert(fcore->ptr_type == TFCP_CONCAT); assert(fcore->ptr_type == TFCP_CONCAT);
CAST_OBJ_NOTNULL(concat, fcore->ptr, TUS_CONCAT_MAGIC); CAST_OBJ_NOTNULL(concat, fcore->ptr, TUS_CONCAT_MAGIC);
for (i = 0; i < concat->n; i++) { for (i = 0; i < concat->n; i++) {
...@@ -333,9 +341,9 @@ tus_file_final_urls(VRT_CTX, const struct tus_file_core *fcore, const char *pfx) ...@@ -333,9 +341,9 @@ tus_file_final_urls(VRT_CTX, const struct tus_file_core *fcore, const char *pfx)
fdisk = part->disk; fdisk = part->disk;
CHECK_OBJ_NOTNULL(fdisk, VMOD_TUS_FILE_DISK_MAGIC); CHECK_OBJ_NOTNULL(fdisk, VMOD_TUS_FILE_DISK_MAGIC);
if (i > 0) if (i > 0)
VSB_cat(vsb, " "); (void)VSB_cat(vsb, " ");
VSB_cat(vsb, pfx); (void)VSB_cat(vsb, pfx);
VSB_cat(vsb, fdisk->upload_path); (void)VSB_cat(vsb, fdisk->upload_path);
} }
return (WS_VSB_finish(vsb, ctx->ws, NULL)); return (WS_VSB_finish(vsb, ctx->ws, NULL));
} }
...@@ -381,10 +389,14 @@ static unsigned tus_file_unref_locked(struct tus_file_core *fcore); ...@@ -381,10 +389,14 @@ static unsigned tus_file_unref_locked(struct tus_file_core *fcore);
void void
tus_file_init(void) tus_file_init(void)
{ {
uintmax_t page_size = getpagesize(); size_t sps;
int ps;
AN(page_size); ps = getpagesize();
header_size = RUP2(sizeof(struct tus_file_disk), page_size); assert(ps > 0);
sps = (unsigned)ps;
header_size = RUP2(sizeof(struct tus_file_disk), sps);
assert(header_size >= sizeof(struct tus_file_disk)); assert(header_size >= sizeof(struct tus_file_disk));
} }
...@@ -423,7 +435,7 @@ static void * ...@@ -423,7 +435,7 @@ static void *
tus_mmap_header(int fd) tus_mmap_header(int fd)
{ {
return (mmap(NULL, header_size, PROT_READ | PROT_WRITE, return (mmap(NULL, header_size, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_NORESERVE, fd, 0)); MAP_SHARED | MAP_NORESERVE, fd, (off_t)0));
} }
static void static void
...@@ -461,6 +473,7 @@ tus_file_mmap(struct tus_file_core *fcore) ...@@ -461,6 +473,7 @@ tus_file_mmap(struct tus_file_core *fcore)
{ {
struct tus_file_disk *fdisk; struct tus_file_disk *fdisk;
int prot = PROT_READ; int prot = PROT_READ;
off_t len;
CHECK_OBJ_NOTNULL(fcore, VMOD_TUS_FILE_CORE_MAGIC); CHECK_OBJ_NOTNULL(fcore, VMOD_TUS_FILE_CORE_MAGIC);
Lck_AssertHeld(&fcore->mtx); Lck_AssertHeld(&fcore->mtx);
...@@ -480,19 +493,20 @@ tus_file_mmap(struct tus_file_core *fcore) ...@@ -480,19 +493,20 @@ tus_file_mmap(struct tus_file_core *fcore)
assert(fdisk->upload_length > 0); assert(fdisk->upload_length > 0);
assert(fdisk->upload_offset <= fdisk->upload_length); assert(fdisk->upload_offset <= fdisk->upload_length);
if (fdisk->upload_offset < fdisk->upload_length) { if (fdisk->upload_offset < fdisk->upload_length) {
len = (off_t)header_size;
len += fdisk->upload_length;
prot |= PROT_WRITE; prot |= PROT_WRITE;
// XXX error handling // XXX error handling
AZ(fallocate(fcore->fd, 0, 0, AZ(fallocate(fcore->fd, (int)0, (off_t)0, len));
header_size + fdisk->upload_length));
} }
fcore->ptr = mmap(NULL, fdisk->upload_length, prot, fcore->ptr = mmap(NULL, (size_t)fdisk->upload_length, prot,
MAP_SHARED | MAP_NORESERVE, fcore->fd, header_size); MAP_SHARED | MAP_NORESERVE, fcore->fd, (off_t)header_size);
AN(fcore->ptr); AN(fcore->ptr);
fcore->ptr_type = (prot & PROT_WRITE) ? fcore->ptr_type = (prot & PROT_WRITE) ?
TFCP_MMAP_RW : TFCP_MMAP_RO; TFCP_MMAP_RW : TFCP_MMAP_RO;
tus_file_close(fcore); tus_file_close(fcore);
fcore->len = fdisk->upload_length; fcore->len = (size_t)fdisk->upload_length;
} }
static void static void
...@@ -605,8 +619,9 @@ ref_transfer(struct tus_file_core *fcore) ...@@ -605,8 +619,9 @@ ref_transfer(struct tus_file_core *fcore)
r = fcore->srvref; r = fcore->srvref;
fcore->srvref = 0; fcore->srvref = 0;
assert(r <= INT_MAX);
fcore->ref += r; fcore->ref += (int)r;
assert(fcore->ref > 0); assert(fcore->ref > 0);
return (r); return (r);
} }
...@@ -658,7 +673,7 @@ tus_file_del(struct tus_file_core **fcorep) ...@@ -658,7 +673,7 @@ tus_file_del(struct tus_file_core **fcorep)
CHECK_OBJ_NOTNULL(*fcorep, VMOD_TUS_FILE_CORE_MAGIC); CHECK_OBJ_NOTNULL(*fcorep, VMOD_TUS_FILE_CORE_MAGIC);
tus_file_remove(*fcorep); tus_file_remove(*fcorep);
tus_touch(*fcorep, 0); tus_touch(*fcorep, (VCL_DURATION)0);
tus_file_unlock(fcorep); tus_file_unlock(fcorep);
} }
...@@ -683,14 +698,14 @@ tus_file_shutdown(struct VPFX(tus_server) *srv) ...@@ -683,14 +698,14 @@ tus_file_shutdown(struct VPFX(tus_server) *srv)
struct tus_files *files = tus_server_files(srv); struct tus_files *files = tus_server_files(srv);
tus_server_lock(srv); tus_server_lock(srv);
for (fcore = VSPLAY_MIN(tus_files, files); fcore = VSPLAY_MIN(tus_files, files);
fcore != NULL; while (fcore != NULL) {
fcore = next) {
next = VSPLAY_NEXT(tus_files, files, fcore); next = VSPLAY_NEXT(tus_files, files, fcore);
REPLACE(fcore->filename, NULL); // prevent unlink REPLACE(fcore->filename, NULL); // prevent unlink
Lck_Lock(&fcore->mtx); Lck_Lock(&fcore->mtx);
tus_file_del_shutdown(&fcore); tus_file_del_shutdown(&fcore);
AZ(fcore); AZ(fcore);
fcore = next;
} }
tus_server_unlock(srv); tus_server_unlock(srv);
} }
...@@ -699,7 +714,7 @@ tus_file_shutdown(struct VPFX(tus_server) *srv) ...@@ -699,7 +714,7 @@ tus_file_shutdown(struct VPFX(tus_server) *srv)
static unsigned static unsigned
tus_file_srvref(struct tus_file_core *fcore) tus_file_srvref(struct tus_file_core *fcore)
{ {
int r; unsigned r;
CHECK_OBJ_NOTNULL(fcore, VMOD_TUS_FILE_CORE_MAGIC); CHECK_OBJ_NOTNULL(fcore, VMOD_TUS_FILE_CORE_MAGIC);
tus_server_AssertLocked(fcore->server); tus_server_AssertLocked(fcore->server);
...@@ -732,12 +747,13 @@ tus_file_unref_locked(struct tus_file_core *fcore) ...@@ -732,12 +747,13 @@ tus_file_unref_locked(struct tus_file_core *fcore)
CHECK_OBJ_NOTNULL(fcore, VMOD_TUS_FILE_CORE_MAGIC); CHECK_OBJ_NOTNULL(fcore, VMOD_TUS_FILE_CORE_MAGIC);
Lck_AssertHeld(&fcore->mtx); Lck_AssertHeld(&fcore->mtx);
r = --fcore->ref + fcore->srvref; r = --fcore->ref;
Lck_Unlock(&fcore->mtx); Lck_Unlock(&fcore->mtx);
r += (int)fcore->srvref;
assert (r >= 0); assert (r >= 0);
if (r == 0) if (r == 0)
tus_file_fini(fcore); tus_file_fini(fcore);
return (r); return ((unsigned)r);
} }
static unsigned static unsigned
...@@ -758,7 +774,7 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename) ...@@ -758,7 +774,7 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename)
struct stat st; struct stat st;
int fd = -1; int fd = -1;
const char *err; const char *err;
ssize_t sz; off_t sz;
tus_server_AssertLocked(srv); tus_server_AssertLocked(srv);
...@@ -805,8 +821,9 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename) ...@@ -805,8 +821,9 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename)
goto err; goto err;
} }
sz = (uintmax_t)st.st_size - header_size; // checked above
assert(sz >= 0); assert(st.st_size >= (off_t)header_size);
sz = st.st_size - (off_t)header_size;
/* /*
* if data was written before we updated the offset, * if data was written before we updated the offset,
* we truncate to avoid potentially corrupted data * we truncate to avoid potentially corrupted data
...@@ -815,7 +832,7 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename) ...@@ -815,7 +832,7 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename)
// .done() called & truncated // .done() called & truncated
} }
else if (fdisk->upload_offset < sz) { else if (fdisk->upload_offset < sz) {
AZ(ftruncate(fd, header_size + fdisk->upload_offset)); AZ(ftruncate(fd, (off_t)header_size + fdisk->upload_offset));
fprintf(stderr, "tus add %s: truncated to %zd\n", filename, sz); fprintf(stderr, "tus add %s: truncated to %zd\n", filename, sz);
} }
else if (fdisk->upload_offset > sz) { else if (fdisk->upload_offset > sz) {
...@@ -903,7 +920,7 @@ tus_file_lookup(struct VPFX(tus_server) *srv, const char *upload_path) ...@@ -903,7 +920,7 @@ tus_file_lookup(struct VPFX(tus_server) *srv, const char *upload_path)
{ {
struct tus_file_core fcore, *found; struct tus_file_core fcore, *found;
struct tus_file_disk needle; struct tus_file_disk needle;
unsigned l = strlen(upload_path); size_t l = strlen(upload_path);
if (l >= TUS_PATH_MAX) { if (l >= TUS_PATH_MAX) {
errno = ENAMETOOLONG; errno = ENAMETOOLONG;
...@@ -914,7 +931,7 @@ tus_file_lookup(struct VPFX(tus_server) *srv, const char *upload_path) ...@@ -914,7 +931,7 @@ tus_file_lookup(struct VPFX(tus_server) *srv, const char *upload_path)
tus_file_fdisk_init(&needle); tus_file_fdisk_init(&needle);
strcpy(needle.upload_path, upload_path); strcpy(needle.upload_path, upload_path);
needle.upload_path_length = l; needle.upload_path_length = (unsigned)l;
fcore.disk = &needle; fcore.disk = &needle;
found = VSPLAY_FIND(tus_files, tus_server_files(srv), &fcore); found = VSPLAY_FIND(tus_files, tus_server_files(srv), &fcore);
...@@ -990,10 +1007,10 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type, ...@@ -990,10 +1007,10 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
/* there is no mkostempat() */ /* there is no mkostempat() */
AN(VSB_init(vsb_path, buf, sizeof buf)); AN(VSB_init(vsb_path, buf, sizeof buf));
VSB_cat(vsb_path, tus_server_basedir(srv)); AZ(VSB_cat(vsb_path, tus_server_basedir(srv)));
VSB_cat(vsb_path, "/" TUS_FILE_PFX); AZ(VSB_cat(vsb_path, "/" TUS_FILE_PFX));
tus_name_rnd(vsb_path); tus_name_rnd(vsb_path);
VSB_cat(vsb_path, TUS_FILE_SUFF); AZ(VSB_cat(vsb_path, TUS_FILE_SUFF));
AZ(VSB_finish(vsb_path)); AZ(VSB_finish(vsb_path));
fd = mkostemp(VSB_data(vsb_path), O_APPEND | O_CLOEXEC); fd = mkostemp(VSB_data(vsb_path), O_APPEND | O_CLOEXEC);
...@@ -1008,7 +1025,7 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type, ...@@ -1008,7 +1025,7 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
path = VSB_data(vsb_path); path = VSB_data(vsb_path);
VSB_fini(vsb_path); VSB_fini(vsb_path);
if (fallocate(fd, 0, 0, header_size)) { if (fallocate(fd, (int)0, (off_t)0, (off_t)header_size)) {
VSLb(ctx->vsl, SLT_Error, "%s: fallocate(%s) failed: %d (%s)", VSLb(ctx->vsl, SLT_Error, "%s: fallocate(%s) failed: %d (%s)",
tus_server_name(srv), path, tus_server_name(srv), path,
errno, strerror(errno)); errno, strerror(errno));
...@@ -1041,18 +1058,24 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type, ...@@ -1041,18 +1058,24 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
fdisk->type = type; fdisk->type = type;
fdisk->upload_path_length = strlen(upload_path); l = strlen(upload_path);
AN(fdisk->upload_path_length); AN(l);
assert(l < TUS_PATH_MAX);
fdisk->upload_path_length = (unsigned)l;
strcpy(fdisk->upload_path, upload_path); strcpy(fdisk->upload_path, upload_path);
if (upload_path[fdisk->upload_path_length - 1] != '/') if (upload_path[fdisk->upload_path_length - 1] != '/')
fdisk->upload_path[fdisk->upload_path_length++] = '/'; fdisk->upload_path[fdisk->upload_path_length++] = '/';
strcpy(fdisk->upload_path + fdisk->upload_path_length, id); strcpy(fdisk->upload_path + fdisk->upload_path_length, id);
fdisk->upload_path_length += strlen(id); l = strlen(id);
assert(l < TUS_PATH_MAX);
fdisk->upload_path_length += (unsigned)l;
assert(fdisk->upload_path_length < TUS_PATH_MAX); assert(fdisk->upload_path_length < TUS_PATH_MAX);
if (metadata && *metadata != '\0') { if (metadata && *metadata != '\0') {
fdisk->metadata_length = strlen(metadata); l = strlen(metadata);
assert(fdisk->metadata_length < TUS_METADATA_MAX); assert(l < TUS_METADATA_MAX);
fdisk->metadata_length = (unsigned)l;
strcpy(fdisk->metadata, metadata); strcpy(fdisk->metadata, metadata);
} }
...@@ -1113,18 +1136,19 @@ struct tus_suck { ...@@ -1113,18 +1136,19 @@ struct tus_suck {
static int static int
tus_suck_finish(const struct tus_suck_common *sc, tus_suck_finish(const struct tus_suck_common *sc,
ssize_t written, const void *ptr, ssize_t len) ssize_t written, const void *ptr, size_t len)
{ {
if (written > 0) { assert(len > 0);
*sc->upload_offset += written; if (written < 0 || (size_t)written != len)
if (*sc->upload_offset > sc->max) { return (-1);
errno = EFBIG;
return (-1); assert((size_t)written == len);
}
}
if (written != len) *sc->upload_offset += written;
if (*sc->upload_offset > sc->max) {
errno = EFBIG;
return (-1); return (-1);
}
if (sc->chksum) if (sc->chksum)
tus_chksum_update(sc->ctx, sc->chksum, ptr, len); tus_chksum_update(sc->ctx, sc->chksum, ptr, len);
...@@ -1151,8 +1175,10 @@ tus_suck_fd_f(void *priv, unsigned flush, const void *ptr, ssize_t len) ...@@ -1151,8 +1175,10 @@ tus_suck_fd_f(void *priv, unsigned flush, const void *ptr, ssize_t len)
assert(len > 0); assert(len > 0);
return (tus_suck_finish(&sfd->sc, write(sfd->fd, ptr, len), return (tus_suck_finish(
ptr, len)); &sfd->sc,
write(sfd->fd, ptr, (size_t)len),
ptr, (size_t)len));
} }
static int static int
...@@ -1162,7 +1188,7 @@ tus_suck_fd_truncate_f(void *priv, off_t length) ...@@ -1162,7 +1188,7 @@ tus_suck_fd_truncate_f(void *priv, off_t length)
CAST_OBJ_NOTNULL(sfd, priv, TUS_SUCK_FD_MAGIC); CAST_OBJ_NOTNULL(sfd, priv, TUS_SUCK_FD_MAGIC);
return (ftruncate(sfd->fd, header_size + length)); return (ftruncate(sfd->fd, (off_t)header_size + length));
} }
static inline struct tus_suck_common * static inline struct tus_suck_common *
...@@ -1206,14 +1232,14 @@ tus_suck_mmap_f(void *priv, unsigned flush, const void *ptr, ssize_t len) ...@@ -1206,14 +1232,14 @@ tus_suck_mmap_f(void *priv, unsigned flush, const void *ptr, ssize_t len)
} }
wptr = (char *)sm->ptr + *sc->upload_offset; wptr = (char *)sm->ptr + *sc->upload_offset;
memcpy(wptr, ptr, len); memcpy(wptr, ptr, (size_t)len);
/* XXX write ordering with fdisk flush ? /* XXX write ordering with fdisk flush ?
* *
* maybe we can just truncate all trailing NULs * maybe we can just truncate all trailing NULs
* when reading? * when reading?
*/ */
return (tus_suck_finish(sc, len, ptr, len)); return (tus_suck_finish(sc, len, ptr, (size_t)len));
} }
static int static int
...@@ -1222,16 +1248,24 @@ tus_suck_mmap_truncate_f(void *priv, off_t length) ...@@ -1222,16 +1248,24 @@ tus_suck_mmap_truncate_f(void *priv, off_t length)
struct tus_suck_mmap *sm; struct tus_suck_mmap *sm;
const struct tus_suck_common *sc; const struct tus_suck_common *sc;
void *wptr; void *wptr;
size_t sz;
CAST_OBJ_NOTNULL(sm, priv, TUS_SUCK_MMAP_MAGIC); CAST_OBJ_NOTNULL(sm, priv, TUS_SUCK_MMAP_MAGIC);
sc = &sm->sc; sc = &sm->sc;
assert(length >= 0);
assert(length <= sc->max); assert(length <= sc->max);
if (length >= *sc->upload_offset) if (length >= *sc->upload_offset)
return (0); return (0);
// length < upload_offset
assert(*sc->upload_offset >= 0);
wptr = (char *)sm->ptr + length; wptr = (char *)sm->ptr + length;
memset(wptr, 0, *sc->upload_offset - length); sz = (size_t)*sc->upload_offset;
sz -= (size_t)length;
memset(wptr, 0, sz);
return (0); return (0);
} }
...@@ -1354,7 +1388,7 @@ tus_file_done(struct tus_file_core *fcore, struct tus_file_disk *fdisk, ...@@ -1354,7 +1388,7 @@ tus_file_done(struct tus_file_core *fcore, struct tus_file_disk *fdisk,
need_truncate = (fdisk->location_length == 0); need_truncate = (fdisk->location_length == 0);
strcpy(fdisk->location, url); strcpy(fdisk->location, url);
fdisk->location_length = l; fdisk->location_length = (unsigned)l;
/* /*
* for TUS_FINAL files, we store the list of parts in the data section, * for TUS_FINAL files, we store the list of parts in the data section,
...@@ -1371,7 +1405,7 @@ tus_file_done(struct tus_file_core *fcore, struct tus_file_disk *fdisk, ...@@ -1371,7 +1405,7 @@ tus_file_done(struct tus_file_core *fcore, struct tus_file_disk *fdisk,
fd = tus_file_open(fcore); fd = tus_file_open(fcore);
if (fd >= 0) { if (fd >= 0) {
AZ(ftruncate(fd, header_size)); AZ(ftruncate(fd, (off_t)header_size));
tus_file_close(fcore); tus_file_close(fcore);
} }
return (1); return (1);
...@@ -1408,8 +1442,10 @@ tus_meta_find(const char *meta, const char *key, size_t l, ...@@ -1408,8 +1442,10 @@ tus_meta_find(const char *meta, const char *key, size_t l,
*vp = v; *vp = v;
if (vlp != NULL) { if (vlp != NULL) {
ve = strchr(v, ','); ve = strchr(v, ',');
if (ve != NULL) if (ve != NULL) {
*vlp = ve - v; assert(ve >= v);
*vlp = (size_t)(ve - v);
}
else else
*vlp = strlen(v); *vlp = strlen(v);
} }
...@@ -1443,7 +1479,7 @@ tus_file_meta(VRT_CTX, const struct tus_file_disk *fdisk, ...@@ -1443,7 +1479,7 @@ tus_file_meta(VRT_CTX, const struct tus_file_disk *fdisk,
if (meta == NULL) if (meta == NULL)
return (0); return (0);
*b = tus_b64_decode(ctx, v, vl); *b = tus_b64_decode(ctx, v, (VCL_INT)vl);
return (1); return (1);
} }
...@@ -185,7 +185,7 @@ tus_file_exp_new(void) ...@@ -185,7 +185,7 @@ tus_file_exp_new(void)
AZ(pthread_cond_init(&e->cond, NULL)); AZ(pthread_cond_init(&e->cond, NULL));
AZ(pthread_attr_init(&attr)); AZ(pthread_attr_init(&attr));
AZ(pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN)); AZ(pthread_attr_setstacksize(&attr, (size_t)PTHREAD_STACK_MIN));
AZ(pthread_create(&e->thread, &attr, tus_exp_thread, e)); AZ(pthread_create(&e->thread, &attr, tus_exp_thread, e));
AZ(pthread_attr_destroy(&attr)); AZ(pthread_attr_destroy(&attr));
return (e); return (e);
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "config.h" #include "config.h"
#include <limits.h>
#include "cache/cache.h" #include "cache/cache.h"
#include "vsb.h" #include "vsb.h"
...@@ -38,7 +40,11 @@ ...@@ -38,7 +40,11 @@
static inline char static inline char
hexnibble(unsigned char n) hexnibble(unsigned char n)
{ {
return (n < 0xa ? '0' + n : 'a' + n - 0xa); unsigned char c;
assert(n <= 0xf);
c = n < 0xa ? '0' + n : 'a' + (n - 0xa);
assert(c <= 'f');
return ((char)c);
} }
static VCL_STRING static VCL_STRING
...@@ -83,7 +89,8 @@ tus_hex(VRT_CTX, VCL_BLOB b) ...@@ -83,7 +89,8 @@ tus_hex(VRT_CTX, VCL_BLOB b)
return (""); return ("");
bufl = b->len * 2 + 1; bufl = b->len * 2 + 1;
buf = WS_Alloc(ctx->ws, bufl); assert(bufl <= UINT_MAX);
buf = WS_Alloc(ctx->ws, (unsigned)bufl);
if (buf == NULL) if (buf == NULL)
return (NULL); return (NULL);
...@@ -95,5 +102,5 @@ tus_vsbhex(struct vsb *vsb, VCL_BLOB b) ...@@ -95,5 +102,5 @@ tus_vsbhex(struct vsb *vsb, VCL_BLOB b)
{ {
size_t l = b->len * 2 + 1; size_t l = b->len * 2 + 1;
char buf[l]; char buf[l];
VSB_cat(vsb, tus_hex_buf(buf, l, b)); AZ(VSB_cat(vsb, tus_hex_buf(buf, l, b)));
} }
...@@ -35,10 +35,7 @@ ...@@ -35,10 +35,7 @@
#include <cache/cache.h> #include <cache/cache.h>
#include <vsb.h> #include <vsb.h>
#include "vcc_tus_if.h"
#include "tus_file.h" #include "tus_file.h"
#include "tus_servers.h"
#include "tus_hdr.h" #include "tus_hdr.h"
#include "tus_response.h" #include "tus_response.h"
#include "tus_request.h" #include "tus_request.h"
...@@ -97,7 +94,8 @@ tus_request_complete(VRT_CTX, const struct VPFX(tus_server) *srv, ...@@ -97,7 +94,8 @@ tus_request_complete(VRT_CTX, const struct VPFX(tus_server) *srv,
p = strrchr(fdisk->upload_path, '/'); p = strrchr(fdisk->upload_path, '/');
AN(p); AN(p);
WS_VSB_new(vsb, ctx->ws); WS_VSB_new(vsb, ctx->ws);
VSB_bcat(vsb, fdisk->upload_path, (p - fdisk->upload_path) + 1); (void)VSB_bcat(vsb, fdisk->upload_path,
(p - fdisk->upload_path) + 1);
tus_vsbhex(vsb, b); tus_vsbhex(vsb, b);
http_SetH(ctx->http_req, HTTP_HDR_URL, http_SetH(ctx->http_req, HTTP_HDR_URL,
WS_VSB_finish(vsb, ctx->ws, NULL)); WS_VSB_finish(vsb, ctx->ws, NULL));
...@@ -112,8 +110,8 @@ tus_request_complete(VRT_CTX, const struct VPFX(tus_server) *srv, ...@@ -112,8 +110,8 @@ tus_request_complete(VRT_CTX, const struct VPFX(tus_server) *srv,
http_Unset(ctx->http_req, H_Content_Type); http_Unset(ctx->http_req, H_Content_Type);
if (tus_file_meta(ctx, fdisk, "filetype", &b)) { if (tus_file_meta(ctx, fdisk, "filetype", &b)) {
WS_VSB_new(vsb, ctx->ws); WS_VSB_new(vsb, ctx->ws);
VSB_bcat(vsb, b->blob, b->len); (void)VSB_bcat(vsb, b->blob, (ssize_t)b->len);
VSB_putc(vsb, '\0'); (void)VSB_putc(vsb, '\0');
p = WS_VSB_finish(vsb, ctx->ws, NULL); p = WS_VSB_finish(vsb, ctx->ws, NULL);
if (validhdr(p)) if (validhdr(p))
http_ForceHeader(ctx->http_req, H_Content_Type, p); http_ForceHeader(ctx->http_req, H_Content_Type, p);
...@@ -203,6 +201,7 @@ static VCL_BOOL ...@@ -203,6 +201,7 @@ static VCL_BOOL
tus_metadata_validate(const char *s, struct test_meta *prev) tus_metadata_validate(const char *s, struct test_meta *prev)
{ {
struct test_meta this = {prev, s, 0}; struct test_meta this = {prev, s, 0};
size_t sz;
// key // key
while (1) { while (1) {
...@@ -211,7 +210,9 @@ tus_metadata_validate(const char *s, struct test_meta *prev) ...@@ -211,7 +210,9 @@ tus_metadata_validate(const char *s, struct test_meta *prev)
continue; continue;
} }
if (tus_meta_key_unique(&this, s - this.k) == 0) assert(s >= this.k);
sz = (size_t)(s - this.k);
if (tus_meta_key_unique(&this, sz) == 0)
return (0); return (0);
if (*s == '\0') if (*s == '\0')
...@@ -323,8 +324,10 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv, ...@@ -323,8 +324,10 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
r->fcore = tus_file_lookup(tussrv, url); r->fcore = tus_file_lookup(tussrv, url);
} }
if (r->fcore != NULL) if (r->fcore != NULL) {
r->schemeauth = WS_Copy(ctx->ws, tussrv->schemeauth, -1); r->schemeauth = WS_Copy(ctx->ws,
tus_server_schemeauth(tussrv), -1);
}
lock = tus_file_trylock(&r->fcore); lock = tus_file_trylock(&r->fcore);
tus_server_unlock(tussrv); tus_server_unlock(tussrv);
...@@ -437,8 +440,8 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv, ...@@ -437,8 +440,8 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
if (len != UINTMAX_MAX) { if (len != UINTMAX_MAX) {
if (fdisk->upload_length == -1) if (fdisk->upload_length == -1)
fdisk->upload_length = len; fdisk->upload_length = (ssize_t)len;
else if (len != fdisk->upload_length) { else if ((ssize_t)len != fdisk->upload_length) {
r->s.status = 409; // or 400 ? r->s.status = 409; // or 400 ?
return (0); return (0);
} }
...@@ -456,13 +459,14 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv, ...@@ -456,13 +459,14 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
assert (type != TUS_FINAL); assert (type != TUS_FINAL);
/*lint -e{788} enums not used */
switch (m) { switch (m) {
case PATCH: { case PATCH: {
if (! ct_ok) { if (! ct_ok) {
r->s.status = 415; r->s.status = 415;
return (0); return (0);
} }
if (off != fdisk->upload_offset) { if ((ssize_t)off != fdisk->upload_offset) {
r->s.status = 409; r->s.status = 409;
return (0); return (0);
} }
......
...@@ -44,14 +44,20 @@ const unsigned s_OPTIONS = 1; ...@@ -44,14 +44,20 @@ const unsigned s_OPTIONS = 1;
static const char * const allow = "POST, GET, HEAD, PATCH, DELETE, OPTIONS"; static const char * const allow = "POST, GET, HEAD, PATCH, DELETE, OPTIONS";
// vmod/vmod_std_conversions.c
#define VCL_BYTES_MAX ((INT64_C(1)<<53)-1)
static VCL_BYTES static VCL_BYTES
tus_upload_length(const struct VPFX(tus_server) *tussrv, tus_upload_length(const struct VPFX(tus_server) *tussrv,
const struct tus_file_core *fcore) const struct tus_file_core *fcore)
{ {
VCL_BYTES srvmax, max; VCL_BYTES srvmax;
struct statvfs fs; struct statvfs fs;
size_t spc;
srvmax = tus_server_max(tussrv); srvmax = tus_server_max(tussrv);
assert(srvmax >= 0);
assert(srvmax <= VCL_BYTES_MAX);
if (fcore != NULL && fcore->fd >= 0) { if (fcore != NULL && fcore->fd >= 0) {
if (fstatvfs(fcore->fd, &fs)) if (fstatvfs(fcore->fd, &fs))
...@@ -59,8 +65,10 @@ tus_upload_length(const struct VPFX(tus_server) *tussrv, ...@@ -59,8 +65,10 @@ tus_upload_length(const struct VPFX(tus_server) *tussrv,
} else if (statvfs(tus_server_basedir(tussrv), &fs)) } else if (statvfs(tus_server_basedir(tussrv), &fs))
return (srvmax); return (srvmax);
max = fs.f_bavail * fs.f_frsize; spc = fs.f_bavail * fs.f_frsize;
return (max < srvmax ? max : srvmax); if (spc < (size_t)srvmax)
return ((VCL_BYTES)spc);
return (srvmax);
} }
static void static void
...@@ -130,11 +138,10 @@ tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv, ...@@ -130,11 +138,10 @@ tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv,
loc); loc);
} }
if (resp->s.status == 301) { VRT_l_resp_status(ctx, (VCL_INT)resp->s.status);
VRT_l_resp_status(ctx, resp->s.status); if (resp->s.status == 301)
return; return;
}
VRT_l_resp_status(ctx, resp->s.status);
if (resp->s.reason != NULL) { if (resp->s.reason != NULL) {
VRT_l_resp_reason(ctx, resp->s.reason, vrt_null_strands); VRT_l_resp_reason(ctx, resp->s.reason, vrt_null_strands);
// FCK H2 - stupid idea to eliminate the reason // FCK H2 - stupid idea to eliminate the reason
...@@ -199,6 +206,7 @@ tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv, ...@@ -199,6 +206,7 @@ tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv,
case TUS_PARTIAL: case TUS_PARTIAL:
http_ForceHeader(r, hdr_concat, "partial"); http_ForceHeader(r, hdr_concat, "partial");
break; break;
case _TUS_TYPE_LIMIT:
default: default:
INCOMPL(); INCOMPL();
} }
......
...@@ -52,3 +52,4 @@ VCL_BYTES tus_server_multipart(const struct VPFX(tus_server) *s); ...@@ -52,3 +52,4 @@ VCL_BYTES tus_server_multipart(const struct VPFX(tus_server) *s);
struct vmod_blobdigest_digest * tus_server_digest( struct vmod_blobdigest_digest * tus_server_digest(
const struct VPFX(tus_server) *s); const struct VPFX(tus_server) *s);
struct tus_exp *tus_server_exp(const struct VPFX(tus_server) *); struct tus_exp *tus_server_exp(const struct VPFX(tus_server) *);
const char * tus_server_schemeauth(const struct VPFX(tus_server) *s);
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include <cache/cache.h> #include <cache/cache.h>
#include "vcc_tus_if.h"
#include "tus_file.h" #include "tus_file.h"
#include "tus_servers.h" #include "tus_servers.h"
...@@ -136,3 +134,10 @@ tus_server_exp(const struct VPFX(tus_server) *s) ...@@ -136,3 +134,10 @@ tus_server_exp(const struct VPFX(tus_server) *s)
CHECK_OBJ_NOTNULL(s, VMOD_TUS_SERVER_MAGIC); CHECK_OBJ_NOTNULL(s, VMOD_TUS_SERVER_MAGIC);
return (s->exp); return (s->exp);
} }
const char *
tus_server_schemeauth(const struct VPFX(tus_server) *s)
{
CHECK_OBJ_NOTNULL(s, VMOD_TUS_SERVER_MAGIC);
return (s->schemeauth);
}
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
#include <vtree.h> #include <vtree.h>
struct vmod_blobdigest_digest;
struct tus_exp;
/* ============================================================ /* ============================================================
* global server splay tree * global server splay tree
*/ */
......
...@@ -80,12 +80,19 @@ tus_objsetattr(struct worker *wrk, struct objcore *oc, ...@@ -80,12 +80,19 @@ tus_objsetattr(struct worker *wrk, struct objcore *oc,
enum obj_attr attr, ssize_t len, const void *ptr); enum obj_attr attr, ssize_t len, const void *ptr);
static const struct obj_methods obj_tus = { static const struct obj_methods obj_tus = {
.objfree = tus_objfree, /* required */
.objiterator = tus_objiterator, .objfree = tus_objfree,
.objgetspace = tus_objgetspace, .objiterator = tus_objiterator,
.objextend = tus_objextend, .objgetspace = tus_objgetspace,
.objgetattr = tus_objgetattr, .objextend = tus_objextend,
.objsetattr = tus_objsetattr .objgetattr = tus_objgetattr,
.objsetattr = tus_objsetattr,
/* optional */
.objtrimstore = NULL,
.objbocdone = NULL,
.objslim = NULL,
.objtouch = NULL,
.objsetstate = NULL
}; };
// ------------------------------------------------------------ // ------------------------------------------------------------
...@@ -98,6 +105,7 @@ tus_allocobj(struct worker *wrk, const struct stevedore *stv, ...@@ -98,6 +105,7 @@ tus_allocobj(struct worker *wrk, const struct stevedore *stv,
(void) oc; (void) oc;
(void) l; (void) l;
INCOMPL(); INCOMPL();
return (0);
} }
static const struct stevedore stv_tus = { static const struct stevedore stv_tus = {
...@@ -198,6 +206,7 @@ tus_objiterator(struct worker *wrk, struct objcore *oc, ...@@ -198,6 +206,7 @@ tus_objiterator(struct worker *wrk, struct objcore *oc,
len = fcore->len - off; len = fcore->len - off;
if (len > max_write) if (len > max_write)
len = max_write; len = max_write;
assert(len <= SSIZE_MAX);
p = (char *)fcore->ptr + off; p = (char *)fcore->ptr + off;
off += len; off += len;
...@@ -205,7 +214,7 @@ tus_objiterator(struct worker *wrk, struct objcore *oc, ...@@ -205,7 +214,7 @@ tus_objiterator(struct worker *wrk, struct objcore *oc,
if (off == fcore->len && i == c->n) if (off == fcore->len && i == c->n)
flags |= OBJ_ITER_END; flags |= OBJ_ITER_END;
r = func(priv, flags, p, len); r = func(priv, flags, p, (ssize_t)len);
if (r < 0) if (r < 0)
return (r); return (r);
...@@ -215,7 +224,7 @@ tus_objiterator(struct worker *wrk, struct objcore *oc, ...@@ -215,7 +224,7 @@ tus_objiterator(struct worker *wrk, struct objcore *oc,
} while (off < fcore->len); } while (off < fcore->len);
} }
if (r == 0 && (flags & OBJ_ITER_END) == 0) if (r == 0 && (flags & OBJ_ITER_END) == 0)
r = func(priv, flags | OBJ_ITER_END, NULL, 0); r = func(priv, flags | OBJ_ITER_END, NULL, (ssize_t)0);
return (r); return (r);
} }
...@@ -228,6 +237,7 @@ tus_objgetspace(struct worker *wrk, struct objcore *oc, ...@@ -228,6 +237,7 @@ tus_objgetspace(struct worker *wrk, struct objcore *oc,
(void) sz; (void) sz;
(void) ptr; (void) ptr;
INCOMPL(); INCOMPL();
return (0);
} }
static void static void
...@@ -256,6 +266,7 @@ tus_objgetattr(struct worker *wrk, struct objcore *oc, ...@@ -256,6 +266,7 @@ tus_objgetattr(struct worker *wrk, struct objcore *oc,
CAST_OBJ_NOTNULL(c, oc->stobj->priv, TUS_CONCAT_MAGIC); CAST_OBJ_NOTNULL(c, oc->stobj->priv, TUS_CONCAT_MAGIC);
/*lint -e{788} enums not used */
switch (attr) { switch (attr) {
case OA_LEN: case OA_LEN:
l = 0; l = 0;
...@@ -270,6 +281,7 @@ tus_objgetattr(struct worker *wrk, struct objcore *oc, ...@@ -270,6 +281,7 @@ tus_objgetattr(struct worker *wrk, struct objcore *oc,
default: default:
INCOMPL(); INCOMPL();
} }
return (NULL);
} }
static void * static void *
...@@ -282,6 +294,7 @@ enum obj_attr attr, ssize_t len, const void *ptr) ...@@ -282,6 +294,7 @@ enum obj_attr attr, ssize_t len, const void *ptr)
(void) len; (void) len;
(void) ptr; (void) ptr;
INCOMPL(); INCOMPL();
return (NULL);
} }
// helper // helper
...@@ -291,7 +304,7 @@ tus_body_single(struct req *req, struct tus_file_core *fcore) ...@@ -291,7 +304,7 @@ tus_body_single(struct req *req, struct tus_file_core *fcore)
{ {
struct tus_concat *c; struct tus_concat *c;
c = WS_Alloc(req->ws, sizeof *c + sizeof fcore); c = WS_Alloc(req->ws, (unsigned)(sizeof *c + sizeof fcore));
if (c == NULL) if (c == NULL)
return (NULL); return (NULL);
INIT_OBJ(c, TUS_CONCAT_MAGIC); INIT_OBJ(c, TUS_CONCAT_MAGIC);
......
...@@ -49,13 +49,14 @@ const struct vrt_blob *vrt_null_blob = &(struct vrt_blob){ ...@@ -49,13 +49,14 @@ const struct vrt_blob *vrt_null_blob = &(struct vrt_blob){
}; };
int int
main(int argc, char **argv) { main(int argc, char * const *argv) {
void *dlhdl; void *dlhdl;
char buf[256], vcl[64]; char buf[256], vcl[64];
const struct vmod_data *d; const struct vmod_data *d;
const char *name; const char *name;
const char *file; const char *file;
int i, fd; int i, fd;
ssize_t ssz;
if (argc < 3) { if (argc < 3) {
fprintf(stderr, "need 2 arguments\n"); fprintf(stderr, "need 2 arguments\n");
...@@ -71,8 +72,8 @@ main(int argc, char **argv) { ...@@ -71,8 +72,8 @@ main(int argc, char **argv) {
bprintf(vcl, "/tmp/vmod_get_h_%s_XXXXXX", name); bprintf(vcl, "/tmp/vmod_get_h_%s_XXXXXX", name);
fd = mkstemp(vcl); fd = mkstemp(vcl);
assert(fd >= 0); assert(fd >= 0);
i = write(fd, buf, strlen(buf)); ssz = write(fd, buf, strlen(buf));
assert(i > 0); assert(ssz > 0);
i = close(fd); i = close(fd);
assert(i == 0); assert(i == 0);
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <vcl.h> #include <vcl.h>
#include <vrt_obj.h> #include <vrt_obj.h>
//lint -esym(763, tus_tus_server)
#include "vcc_tus_if.h" #include "vcc_tus_if.h"
#include "tus_file.h" #include "tus_file.h"
...@@ -101,9 +102,10 @@ tus_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) ...@@ -101,9 +102,10 @@ tus_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
case VCL_EVENT_DISCARD: return (tus_fini(ctx, priv)); case VCL_EVENT_DISCARD: return (tus_fini(ctx, priv));
case VCL_EVENT_WARM: case VCL_EVENT_WARM:
case VCL_EVENT_COLD: case VCL_EVENT_COLD:
return (0); break;
default: INCOMPL(); default: INCOMPL();
} }
return (0);
} }
/* ============================================================ /* ============================================================
...@@ -160,14 +162,14 @@ static int ...@@ -160,14 +162,14 @@ static int
tus_schemeauth_valid(const char *schemeauth, const char **p) tus_schemeauth_valid(const char *schemeauth, const char **p)
{ {
*p = schemeauth; *p = schemeauth;
if (*p == NULL || strncmp(*p, "http", 4) != 0) if (*p == NULL)
return (0);
if (! TOK(*p, "http"))
return (0); return (0);
*p += 4;
if (**p == 's') if (**p == 's')
(*p)++; (*p)++;
if (strncmp(*p, "://", 3) != 0) if (! TOK(*p, "://"))
return (0); return (0);
*p += 3;
if (**p == '\0') if (**p == '\0')
return (0); return (0);
*p = strchr(*p, '/'); *p = strchr(*p, '/');
...@@ -249,13 +251,13 @@ tus_server__init(VRT_CTX, struct VPFX(tus_server) **tussrvp, ...@@ -249,13 +251,13 @@ tus_server__init(VRT_CTX, struct VPFX(tus_server) **tussrvp,
const char *vcl_name, struct VARGS(server__init) *args) const char *vcl_name, struct VARGS(server__init) *args)
{ {
struct vmod_blobdigest_digest *d = NULL; struct vmod_blobdigest_digest *d = NULL;
struct VPFX(tus_server) *tussrv, needle[1]; struct VPFX(tus_server) *tussrv, needle;
AN(tussrvp); AN(tussrvp);
AZ(*tussrvp); AZ(*tussrvp);
if (args->valid_name_hash) { if (args->valid_name_hash) {
d = tus_hash(args->name_hash, 0); d = tus_hash(args->name_hash, (size_t)0);
if (d == NULL) { if (d == NULL) {
VRT_fail(ctx, "new %s: " VRT_fail(ctx, "new %s: "
"name_hash %s not supported " "name_hash %s not supported "
...@@ -265,10 +267,10 @@ tus_server__init(VRT_CTX, struct VPFX(tus_server) **tussrvp, ...@@ -265,10 +267,10 @@ tus_server__init(VRT_CTX, struct VPFX(tus_server) **tussrvp,
} }
} }
INIT_OBJ(needle, VMOD_TUS_SERVER_MAGIC); INIT_OBJ(&needle, VMOD_TUS_SERVER_MAGIC);
needle->vcl_name = TRUST_ME(vcl_name); needle.vcl_name = TRUST_ME(vcl_name);
tussrv = VSPLAY_FIND(tus_servers, tus_servers, needle); tussrv = VSPLAY_FIND(tus_servers, tus_servers, &needle);
if (tussrv == NULL) if (tussrv == NULL)
tussrv = tus_server_new(ctx, vcl_name, args); tussrv = tus_server_new(ctx, vcl_name, args);
else else
...@@ -357,7 +359,7 @@ tus_task_new(VRT_CTX, const struct VPFX(tus_server) *tussrv) ...@@ -357,7 +359,7 @@ tus_task_new(VRT_CTX, const struct VPFX(tus_server) *tussrv)
return (NULL); return (NULL);
} }
r = WS_Alloc(ctx->ws, sizeof *r); r = WS_Alloc(ctx->ws, (unsigned)sizeof *r);
if (r == NULL) { if (r == NULL) {
VRT_fail(ctx, "WS_Alloc failed"); VRT_fail(ctx, "WS_Alloc failed");
return (NULL); return (NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment