|
@@ -538,6 +538,7 @@ str *dlginfo_body_setversion(subs_t *subs, str *body) {
|
|
char *version_start=0;
|
|
char *version_start=0;
|
|
char version[MAX_INT_LEN + 2]; /* +2 becasue of trailing " and \0 */
|
|
char version[MAX_INT_LEN + 2]; /* +2 becasue of trailing " and \0 */
|
|
int version_len;
|
|
int version_len;
|
|
|
|
+ str* aux_body = NULL;
|
|
|
|
|
|
if (!body) {
|
|
if (!body) {
|
|
return NULL;
|
|
return NULL;
|
|
@@ -564,9 +565,29 @@ str *dlginfo_body_setversion(subs_t *subs, str *body) {
|
|
version_len = snprintf(version, MAX_INT_LEN + 2,"%d\"", subs->version);
|
|
version_len = snprintf(version, MAX_INT_LEN + 2,"%d\"", subs->version);
|
|
if (version_len >= MAX_INT_LEN + 2) {
|
|
if (version_len >= MAX_INT_LEN + 2) {
|
|
LM_ERR("failed to convert 'version' to string\n");
|
|
LM_ERR("failed to convert 'version' to string\n");
|
|
- memcpy(version_start, "00000000000\"", 12);
|
|
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ aux_body= (str*)pkg_malloc(sizeof(str));
|
|
|
|
+ if(aux_body== NULL)
|
|
|
|
+ {
|
|
|
|
+ ERR_MEM(PKG_MEM_STR);
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+ memset(aux_body, 0, sizeof(str));
|
|
|
|
+ aux_body->s= (char*)pkg_malloc( body->len * sizeof(char));
|
|
|
|
+ if(aux_body->s== NULL)
|
|
|
|
+ {
|
|
|
|
+ pkg_free(aux_body);
|
|
|
|
+ ERR_MEM(PKG_MEM_STR);
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+ memcpy(aux_body->s, body->s, body->len);
|
|
|
|
+ aux_body->len= body->len;
|
|
|
|
+
|
|
|
|
+ /* again but on the copied str, no checks needed */
|
|
|
|
+ version_start = strstr(aux_body->s + 34, "version=");
|
|
|
|
+ version_start += 9;
|
|
/* Replace the placeholder 00000000000 with the version.
|
|
/* Replace the placeholder 00000000000 with the version.
|
|
* Put the padding behind the ""
|
|
* Put the padding behind the ""
|
|
*/
|
|
*/
|
|
@@ -574,5 +595,5 @@ str *dlginfo_body_setversion(subs_t *subs, str *body) {
|
|
memcpy(version_start, version, version_len);
|
|
memcpy(version_start, version, version_len);
|
|
memset(version_start + version_len, ' ', 12 - version_len);
|
|
memset(version_start + version_len, ' ', 12 - version_len);
|
|
|
|
|
|
- return NULL;
|
|
|
|
|
|
+ return aux_body;
|
|
}
|
|
}
|