Re: Interfaces to limit string sizes

Michal Čihař <[email protected]>
Newsgroups gmane.linux.drivers.gammu
Message-ID <[email protected]>
Hi

Dne 21.3.2016 v 23:08 Paulo Roberto napsal(a):
> I've been using LibGammu in some projects, it's a great project.
> 
> But I noticed that dealing with strings could be a lot error prone and
> if not careful you could have some security issues.
> I say this because of the use of static string variables and the
> assumption of correctness in the buffer size.

Indeed it does. The buffer sizes are exported as well in gammu-limits.h.

> To solve it in my projects I implemented some new interfaces for the
> functions that I use. Mainly in coding.c and api.c.
> 
> The new functions do the same of the old ones, but add the control of
> limit buffers size. I was not sure about how to name the new functions,
> so I added a '_s' in the name of the old functions.
> 
> Example:
>    CopyUnicodeString => CopyUnicodeString_s
> 
> I'm sending a little patch with these changes. If you approve the
> modification, I would be glad to add equivalent functions for the rest
> of the API when it requires.

I'm not really sure if it's good idea to add second set of API,
especially as your changes basically duplicate existing code, what will
make it really easy to fix only one copy of it in future...

-- 
	Michal Čihař | http://cihar.com/ | https://weblate.org/

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140

_______________________________________________
Gammu-users mailing list - https://lists.sourceforge.net/lists/listinfo/gammu-users
signature.asc (application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJW8P7GAAoJEPSqIp1NWMJFb0kP/2VTBAgQz9kspLMu04OtxMk1
vj53cbNN+aroCJBxr90TDJQrbicv0zUtptTdSGIMvHIv0ti6cvnvvY0JLuWU6TDR
6zaqrLQHvgo1j46gURW6xz9yBFTRo018XzltTS25hGEUGNa+21F9dikI8b5maPNW
hepBU8RENYkuEohhrrH0QDttPXlb/U8ds4SzZV1chYQXs2w1Kmt9KHK3Ft0Wq3de
xwd9eE8lESSb0Kp4cSmb/AGF/Prilvr2JutuU3pk14Zn3U2hrClH9af/yi4IdReT
NmTAGaP3diXg8WAVTSegJ7pMdwSVX6gWgEav6c5xslSBM/EcS7TBdrlJ8CMVhPBK
f/VlW0jrdAldkWqK51HfuiTL+vnUgi1diCdyoaTgRRd/8tUz9hjxXfnBA6nloVoi
TuV9XI3uprE6Stz80Ph16E0WHhehBaBdKqgjEhmTgkj5G9rsL5jvkWdiG35muhbU
rgGpkOjsqd0fyb71w2Qsv45ZxdULFz3hHPh3Z4ygzvfe4zh186FaDVNh2B+swgsu
0ItT930CgSYP437dpLDo8lJBOBcFjOZbg6IGfGLcNh0UtY7xcdOwp4mljF3CCnjc
9nbDUDPRwd6QJQn7jne0w2MtMTBmXa/KUhXG8+EpOpB1cM2XptdTHZcU10Z2CiMe
NN6u441XyuXPCJUfhPl2
=70IG
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.