@@ -30,12 +30,12 @@ static enum pubnub_res inflate_total_to_context_buffer(pubnub_t* pb,
30
30
return PNR_OK ;
31
31
}
32
32
else {
33
- PUBNUB_LOG_ERROR ("Decompressed length[%u ] is smaller than the "
34
- "'unpacked_size' value[%u ]!\n"
33
+ PUBNUB_LOG_ERROR ("Decompressed length[%zu ] is smaller than the "
34
+ "'unpacked_size' value[%zu ]!\n"
35
35
"(Unpacked:['%.*s'])\n" ,
36
- ( unsigned ) dst_buf_size ,
37
- ( unsigned ) out_len ,
38
- (int )dst_buf_size ,
36
+ dst_buf_size ,
37
+ out_len ,
38
+ (long )dst_buf_size ,
39
39
pb -> core .decomp_http_reply );
40
40
}
41
41
break ;
@@ -69,8 +69,8 @@ static enum pubnub_res inflate_total_to_context_buffer(pubnub_t* pb,
69
69
static void swap_reply_buffer (pubnub_t * pb )
70
70
{
71
71
#if PUBNUB_DYNAMIC_REPLY_BUFFER
72
- char * aux_buf = pb -> core .http_reply ;
73
- unsigned aux_buf_len = pb -> core .http_buf_len ;
72
+ char * aux_buf = pb -> core .http_reply ;
73
+ size_t aux_buf_len = pb -> core .http_buf_len ;
74
74
pb -> core .http_reply = pb -> core .decomp_http_reply ;
75
75
pb -> core .http_buf_len = pb -> core .decomp_buf_size ;
76
76
pb -> core .decomp_http_reply = aux_buf ;
@@ -85,6 +85,7 @@ static void swap_reply_buffer(pubnub_t* pb)
85
85
return ;
86
86
}
87
87
88
+
88
89
static enum pubnub_res inflate_total (pubnub_t * pb ,
89
90
const uint8_t * p_in_buf_next ,
90
91
size_t in_buf_size ,
@@ -96,7 +97,7 @@ static enum pubnub_res inflate_total(pubnub_t* pb,
96
97
char * newbuf = (char * )realloc (pb -> core .decomp_http_reply , out_len + 1 );
97
98
if (NULL == newbuf ) {
98
99
PUBNUB_LOG_ERROR ("Failed to reallocate decompression buffer!\n"
99
- "Out length:%lu \n" ,
100
+ "Out length:%zu \n" ,
100
101
out_len );
101
102
return PNR_REPLY_TOO_BIG ;
102
103
}
@@ -105,7 +106,7 @@ static enum pubnub_res inflate_total(pubnub_t* pb,
105
106
#else
106
107
if (out_len >= sizeof pb -> core .decomp_http_reply ) {
107
108
PUBNUB_LOG_ERROR ("Decompression buffer too small!\n"
108
- "Size of buffer:%lu - Out length:%lu \n" ,
109
+ "Size of buffer:%zu - Out length:%zu \n" ,
109
110
sizeof pb -> core .decomp_http_reply ,
110
111
out_len );
111
112
return PNR_REPLY_TOO_BIG ;
@@ -120,6 +121,7 @@ static enum pubnub_res inflate_total(pubnub_t* pb,
120
121
return result ;
121
122
}
122
123
124
+
123
125
enum pubnub_res pbgzip_decompress (pubnub_t * pb )
124
126
{
125
127
const uint8_t * data = (uint8_t * )pb -> core .http_reply ;
@@ -132,16 +134,14 @@ enum pubnub_res pbgzip_decompress(pubnub_t* pb)
132
134
return PNR_BAD_COMPRESSION_FORMAT ;
133
135
}
134
136
if (data [2 ] != 8 ) {
135
- PUBNUB_LOG_ERROR ("Not used 'deflate' compression method (8)!\n "
136
- "Compression method value:%u \n" ,
137
+ PUBNUB_LOG_ERROR ("Unknown compression method %uX - only 'deflate'(8) "
138
+ "is supported! \n" ,
137
139
(unsigned )data [2 ]);
138
140
return PNR_BAD_COMPRESSION_FORMAT ;
139
141
}
140
142
if (data [3 ] != 0 ) {
141
- PUBNUB_LOG_ERROR (
142
- "Pubnub gzip doesn't expect any flags on filename and extras!\n"
143
- "Got gzip flags:%u\n" ,
144
- (unsigned )data [3 ]);
143
+ PUBNUB_LOG_ERROR ("GZIP flags should be 0, but are %uX\n" ,
144
+ (unsigned )data [3 ]);
145
145
return PNR_BAD_COMPRESSION_FORMAT ;
146
146
}
147
147
/* Unpacked message size is placed at the end of the 'gzip' formated message
@@ -151,11 +151,11 @@ enum pubnub_res pbgzip_decompress(pubnub_t* pb)
151
151
unpacked_size |= (uint32_t )data [size - 3 ] << 8 ;
152
152
unpacked_size |= (uint32_t )data [size - 2 ] << 16 ;
153
153
unpacked_size |= (uint32_t )data [size - 1 ] << 24 ;
154
- PUBNUB_LOG_TRACE ("pbgzip_decompress(pb=%p)-Length before:%lu and after "
154
+ PUBNUB_LOG_TRACE ("pbgzip_decompress(pb=%p)-Length before:%zu and after "
155
155
"decompresion:%lu\n" ,
156
156
pb ,
157
- ( long unsigned ) size ,
158
- (long unsigned )unpacked_size );
157
+ size ,
158
+ (unsigned long )unpacked_size );
159
159
size -= (GZIP_HEADER_LENGTH_BYTES + GZIP_FOOTER_LENGTH_BYTES );
160
160
161
161
return inflate_total (
0 commit comments