Commit fb8b9d9f fb8b9d9f7daee8185101e7438039c98f2345ccff by Alain Magloire

minor nit in set_value, and I'm not sure it is a good fix.

1 parent 41d545f2
...@@ -259,14 +259,29 @@ header_set_value (header_t header, const char *fn, const char *fv, int replace) ...@@ -259,14 +259,29 @@ header_set_value (header_t header, const char *fn, const char *fv, int replace)
259 blurb = calloc (header->blurb_len + len + 2, 1); 259 blurb = calloc (header->blurb_len + len + 2, 1);
260 if (blurb == NULL) 260 if (blurb == NULL)
261 return ENOMEM; 261 return ENOMEM;
262 sprintf (blurb, "%s: %s\n", fn, fv); 262
263 sprintf (blurb, "%s: %s", fn, fv);
264
265 /* Strip off trailing newlines. */
266 while (blurb[strlen (blurb) - 1] == '\n')
267 {
268 blurb[strlen (blurb) - 1] = '\0';
269 }
270 len = strlen (blurb);
271 blurb[len] = '\n';
272 len++;
273
274 /* Prepend the rest of the headers. */
263 if (header->blurb) 275 if (header->blurb)
264 { 276 {
265 memcpy (blurb + len, header->blurb, header->blurb_len); 277 memcpy (blurb + len, header->blurb, header->blurb_len);
266 free (header->blurb); 278 free (header->blurb);
267 } 279 }
280 else
281 blurb [len] = '\n';
282
268 /* before parsing the new blurb make sure it is properly terminated 283 /* before parsing the new blurb make sure it is properly terminated
269 by \n\n. The trailing NL separtor. */ 284 by \n\n. The trailing NL separator. */
270 if (blurb[header->blurb_len + len - 1] != '\n' 285 if (blurb[header->blurb_len + len - 1] != '\n'
271 || blurb[header->blurb_len + len - 2] != '\n') 286 || blurb[header->blurb_len + len - 2] != '\n')
272 { 287 {
......