A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-July/127452.html below:

Use strncat() instead of strcat() to silence some warnings.

[Python-Dev] cpython: Use strncat() instead of strcat() to silence some warnings.Serhiy Storchaka storchaka at gmail.com
Sat Jul 20 14:23:46 CEST 2013
20.07.13 15:12, christian.heimes написав(ла):
> http://hg.python.org/cpython/rev/c92f4172d122
> changeset:   84723:c92f4172d122
> user:        Christian Heimes <christian at cheimes.de>
> date:        Sat Jul 20 14:11:28 2013 +0200
> summary:
>    Use strncat() instead of strcat() to silence some warnings.
> CID 486616, CID 486617, CID 486615
>
> files:
>    Modules/ossaudiodev.c |  6 +++---
>    1 files changed, 3 insertions(+), 3 deletions(-)
>
>
> diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
> --- a/Modules/ossaudiodev.c
> +++ b/Modules/ossaudiodev.c
> @@ -245,7 +245,7 @@
>       int arg;
>
>       assert(strlen(fname) <= 30);
> -    strcat(argfmt, fname);
> +    strncat(argfmt, fname, 30);
>       if (!PyArg_ParseTuple(args, argfmt, &arg))
>           return NULL;
>
> @@ -270,7 +270,7 @@
>       int arg = 0;
>
>       assert(strlen(fname) <= 30);
> -    strcat(argfmt, fname);
> +    strncat(argfmt, fname, 30);
>       if (!PyArg_ParseTuple(args, argfmt, &arg))
>           return NULL;
>
> @@ -290,7 +290,7 @@
>       int rv;
>
>       assert(strlen(fname) <= 30);
> -    strcat(argfmt, fname);
> +    strncat(argfmt, fname, 30);
>       if (!PyArg_ParseTuple(args, argfmt))
>           return NULL;

This will wrong when strlen(fname) is 30. strncat() will copy only 30 
bytes, without terminal NUL.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4