View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0009291 | GNUnet | util library | public | 2024-10-22 16:14 | 2024-10-29 20:56 |
| Reporter | fefe | Assigned To | schanzen | ||
| Priority | normal | Severity | minor | Reproducibility | have not tried |
| Status | closed | Resolution | no change required | ||
| Target Version | 0.22.2 | Fixed in Version | 0.22.2 | ||
| Summary | 0009291: GNUNET_CONFIGURATION_serialize: confused code | ||||
| Description | 1190 len = GNUNET_asprintf (&cbuf, 1191 "[%s]\n", 1192 sec->name); 1193 GNUNET_assert (0 < len); 1194 GNUNET_memcpy (mem + c_size, 1195 cbuf, 1196 len); 1197 c_size += len; 1198 GNUNET_free (cbuf); Just call GNUNET_vsnprintf and skip the memory allocation and deallocation. You even gain a buffer overflow check that way. Same advice applies further down in the same function: 1216 len = GNUNET_asprintf (&cbuf, "%s = %s\n", ent->key, val); 1217 GNUNET_free (val); 1218 GNUNET_memcpy (mem + c_size, cbuf, len); 1219 c_size += len; 1220 GNUNET_free (cbuf); I would, in fact, recommend refactoring the whole function. It does things in a very inefficient way (using memmove repeatedly to escape \n to \\n). | ||||
| Tags | No tags attached. | ||||
|
|
Not sure what exactly to do here. GNUNET_vsnprintf does not exists. vsnprintf requires us to pre-allocate the buffer. We can do that, of course, but I see no benefit as this is not a performance-critical function. |
|
|
Also GNUNET_asprintf already calls vsnprintf 0009286 |
|
|
GNUNET_asprintf already calls vsnprintf only. Refactoring/improvement of GNUNET_CONFIGURATION_serialize is not clear enough and requires a new issue with more detailed targeted description. |
|
|
Released |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2024-10-22 16:14 | fefe | New Issue | |
| 2024-10-23 13:19 | schanzen | Target Version | => 0.22.2 |
| 2024-10-23 21:19 | schanzen | Note Added: 0023578 | |
| 2024-10-25 15:33 | schanzen | Note Added: 0023601 | |
| 2024-10-25 15:33 | schanzen | Relationship added | related to 0009286 |
| 2024-10-29 13:17 | schanzen | Assigned To | => schanzen |
| 2024-10-29 13:17 | schanzen | Status | new => resolved |
| 2024-10-29 13:17 | schanzen | Resolution | open => no change required |
| 2024-10-29 13:17 | schanzen | Fixed in Version | => 0.22.2 |
| 2024-10-29 13:17 | schanzen | Note Added: 0023615 | |
| 2024-10-29 20:56 | schanzen | Note Added: 0023623 | |
| 2024-10-29 20:56 | schanzen | Status | resolved => closed |