View Issue Details

IDProjectCategoryView StatusLast Update
0009286GNUnetutil librarypublic2024-10-29 19:56
Reporterfefe Assigned Toschanzen Due Date
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Target Version0.22.2Fixed in Version0.22.2 
Summary0009286: GNUNET_asprintf: don't call vsprintf
Description  363 int
  364 GNUNET_asprintf (char **buf,
  365 const char *format,
  366 ...)
  367 {
  368 int ret;
  369 va_list args;
  370
  371 va_start (args,
  372 format);
  373 ret = vsnprintf (NULL,
  374 0,
  375 format,
  376 args);
  377 va_end (args);
  378 GNUNET_assert (ret >= 0);
  379 *buf = GNUNET_malloc (ret + 1);
  380 va_start (args, format);
  381 ret = vsprintf (*buf,
  382 format,
  383 args);
  384 va_end (args);
  385 return ret;
  386 }

It is possible to construct a format string that will cause the resulting length to cause overflow in vsnprintf.
As a defense in depth measure, don't call vsprintf but vsnprintf.
TagsNo tags attached.

Relationships

related to 0009291 closedschanzen GNUNET_CONFIGURATION_serialize: confused code 

Activities

schanzen

2024-10-25 13:35

administrator   ~0023602

I do not understand this report. The function already calls vsnprintf to get the number of bytes required. Then it allocates a buffer of sufficient length and then calls vsprintf on that buffer. This will obviously then never overflow?
We could call vsnprintf again, of course. But with 0 actual impact (?)

schanzen

2024-10-29 12:15

administrator   ~0023614

Fix committed to master branch.

schanzen

2024-10-29 19:56

administrator   ~0023621

Released

Issue History

Date ModifiedUsernameFieldChange
2024-10-21 13:51fefeNew Issue
2024-10-23 11:19schanzenTarget Version => 0.22.2
2024-10-25 13:33schanzenRelationship addedrelated to 0009291
2024-10-25 13:35schanzenNote Added: 0023602
2024-10-25 13:35schanzenAssigned To => schanzen
2024-10-25 13:35schanzenStatusnew => assigned
2024-10-29 12:15schanzen
2024-10-29 12:15schanzenNote Added: 0023614
2024-10-29 12:15schanzenStatusassigned => resolved
2024-10-29 12:15schanzenResolutionopen => fixed
2024-10-29 19:53schanzenFixed in Version => 0.22.2
2024-10-29 19:56schanzenNote Added: 0023621
2024-10-29 19:56schanzenStatusresolved => closed