[gnutls-devel] GnuTLS | psktool: encode username if it contains special character (!1345)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Fri Oct 30 09:28:33 CET 2020




Daiki Ueno commented on a discussion on src/psk.c: https://gitlab.com/gnutls/gnutls/-/merge_requests/1345#note_438807540

> +			fprintf(stderr, "HEX encoding error\n");
> +			ret = -1;
> +			goto out;
> +		}
> +
> +		/* prepend '#' */
> +		new_data = gnutls_realloc(_username.data, _username.size + 2);
> +		if (!new_data) {
> +			ret = -1;
> +			goto out;
> +		}
> +		memmove(_username.data + 1, _username.data, _username.size);
> +		new_data[0] = '#';
> +		new_data[_username.size] = '\0';
> +		_username.data = (void *)new_data;
> +		_username.size += 1;

Hmm, I think we should keep the invariant that `.size` doesn't count the NULL terminator. Instead, we probably should omit `-1` in the below lines:
```c
                if (strncmp(p, (const char *) _username.data,
                            MAX(_username.size - 1,
                                (unsigned int) (pp - p))) == 0) {
```
though I have actually no idea why this is substring match.

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1345#note_438807540
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20201030/633cf724/attachment.html>


More information about the Gnutls-devel mailing list