View Issue Details

IDProjectCategoryView StatusLast Update
0008047GNUnetutil librarypublic2024-03-07 20:26
Reporterfefe Assigned ToChristian Grothoff  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Fixed in Version0.21.0 
Summary0008047: GNUNET_STRINGS_parse_socket_addr: superfluous strdup call
DescriptionThis is in gnunet/src/lib/util/strings.c:

1149 size_t
1150 GNUNET_STRINGS_parse_socket_addr (const char *addr,
1151 uint8_t *af,
1152 struct sockaddr **sa)
1153 {
1154 char *cp = GNUNET_strdup (addr);
1155
1156 *af = AF_UNSPEC;
1157 if ('[' == *addr)
1158 {
1159 /* IPv6 */
1160 *sa = GNUNET_malloc (sizeof(struct sockaddr_in6));
1161 if (GNUNET_OK !=
1162 GNUNET_STRINGS_to_address_ipv6 (cp,
1163 strlen (cp),
1164 (struct sockaddr_in6 *) *sa))
1165 {
1166 GNUNET_free (*sa);
1167 *sa = NULL;
1168 GNUNET_free (cp);
1169 return 0;
1170 }
1171 *af = AF_INET6;
1172 GNUNET_free (cp);
1173 return sizeof(struct sockaddr_in6);
1174 }
1175 else
1176 {
1177 /* IPv4 */
1178 *sa = GNUNET_malloc (sizeof(struct sockaddr_in));
1179 if (GNUNET_OK !=
1180 GNUNET_STRINGS_to_address_ipv4 (cp,
1181 strlen (cp),
1182 (struct sockaddr_in *) *sa))
1183 {
1184 GNUNET_free (*sa);
1185 *sa = NULL;
1186 GNUNET_free (cp);
1187 return 0;
1188 }
1189 *af = AF_INET;
1190 GNUNET_free (cp);
1191 return sizeof(struct sockaddr_in);
1192 }

Note that cp is never written to after the strdup. The strdup appears to be superfluous. You might as well just pass the incoming string pointer on.
TagsNo tags attached.

Activities

Christian Grothoff

2024-01-09 19:02

manager   ~0020841

Fix committed to master branch.

schanzen

2024-03-07 20:26

administrator   ~0021799

0.21 released

Related Changesets

gnunet: master 6dcb2075

2024-01-09 20:02

Christian Grothoff


Details Diff
fix 0008047 Affected Issues
0008047
mod - src/lib/util/strings.c Diff File

Issue History

Date Modified Username Field Change
2024-01-09 17:06 fefe New Issue
2024-01-09 19:02 Christian Grothoff Changeset attached => gnunet master 6dcb2075
2024-01-09 19:02 Christian Grothoff Note Added: 0020841
2024-01-09 19:02 Christian Grothoff Assigned To => Christian Grothoff
2024-01-09 19:02 Christian Grothoff Status new => resolved
2024-01-09 19:02 Christian Grothoff Resolution open => fixed
2024-01-09 20:10 Christian Grothoff Project Taler => GNUnet
2024-01-09 20:10 Christian Grothoff Category other => util library
2024-03-07 20:26 schanzen Fixed in Version => 0.21.0
2024-03-07 20:26 schanzen Note Added: 0021799
2024-03-07 20:26 schanzen Status resolved => closed