Browse code

posops: adjust offset on negative index for update ops

Daniel-Constantin Mierla authored on 22/09/2021 19:19:01
Showing 1 changed files
... ...
@@ -153,7 +153,7 @@ static int ki_posops_pos_append(sip_msg_t *msg, int idx, str *val)
153 153
 	}
154 154
 
155 155
 	if(idx<0) {
156
-		offset = msg->len + idx + 1;
156
+		offset = msg->len + idx;
157 157
 	} else {
158 158
 		offset = idx;
159 159
 	}
... ...
@@ -206,7 +206,7 @@ static int ki_posops_pos_insert(sip_msg_t *msg, int idx, str *val)
206 206
 	}
207 207
 
208 208
 	if(idx<0) {
209
-		offset = msg->len + idx + 1;
209
+		offset = msg->len + idx;
210 210
 	} else {
211 211
 		offset = idx;
212 212
 	}
... ...
@@ -259,7 +259,7 @@ static int ki_posops_pos_rm(sip_msg_t *msg, int idx, int len)
259 259
 		return -1;
260 260
 	}
261 261
 	if(idx<0) {
262
-		offset = msg->len + idx + 1;
262
+		offset = msg->len + idx;
263 263
 	} else {
264 264
 		offset = idx;
265 265
 	}