From 5f939fd666102fec795c5c2f4cb793845c2dc08e Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Tue, 12 Sep 2023 18:04:09 +0200 Subject: [PATCH] try anyway --- src/zap.zig | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/zap.zig b/src/zap.zig index fab15dd..bbf5e94 100644 --- a/src/zap.zig +++ b/src/zap.zig @@ -628,10 +628,20 @@ pub fn Fiobj2HttpParam(o: fio.FIOBJ, a: std.mem.Allocator, dupe_string: bool) !? } else { // the data const data_len = fio.fiobj_data_len(data); - const data_buf = fio.fiobj_data_read(data, data_len); + var data_buf = fio.fiobj_data_read(data, data_len); if (data_len < 0) { std.log.warn("WARNING: HTTP param binary file size negative: {d}\n", .{data_len}); + + // try to read anyway + std.log.warn("WARNING: Attempting to read anyway\n", .{}); + data_buf = fio.fiobj_data_read(data, 4096); + if (data_buf.len > 0) { + data_slice = data_buf.data[0..data_buf.len]; + } else { + std.log.warn("WARNING: HTTP param binary file buffer size negative: {d}\n", .{data_buf.len}); + data_slice = "(zap: invalid data: negative BUFFER size)"; + } } else { if (data_buf.len != data_len) { std.log.warn("WARNING: HTTP param binary file size mismatch: should {d}, is: {d}\n", .{ data_len, data_buf.len });