Skip to content

Commit b1a2d0c

Browse files
author
xvass
committed
Warning fixes - strncpy replaced with memcpy
1 parent f20725e commit b1a2d0c

File tree

8 files changed

+6
-7
lines changed

8 files changed

+6
-7
lines changed

Blowfish.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ char *Blowfish::encryptpass( QString passwd) const
9696

9797
char *buf = ( char * )calloc ( 512, sizeof(*buf) );
9898
char *password = passwd.toLatin1().data();
99-
strncpy ( buf,password,strlen(password));
99+
memcpy ( buf,password,strlen(password));
100100

101101
/*
102102
* The crypt_r function does the same thing as crypt, but takes an extra parameter

Makefile

100755100644
File mode changed.

Md5.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ char *Md5::encryptpass( QString passwd) const
3737

3838
char *buf = ( char * )calloc ( 512, sizeof(*buf) );
3939
char *password = passwd.toLatin1().data();
40-
strncpy ( buf,password,strlen(password));
40+
memcpy ( buf,password,strlen(password));
4141

4242
/*
4343
* The crypt_r function does the same thing as crypt,

UserManager

456 Bytes
Binary file not shown.

UserManager.pro

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
######################################################################
2-
# Automatically generated by qmake (3.1) Sun Jul 5 05:08:17 2020
2+
# Automatically generated by qmake (3.1) Sun Jul 5 05:32:10 2020
33
######################################################################
44

55
TEMPLATE = app

sha256.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ char *sha256::encryptpass( QString passwd) const
4343

4444
char *buf = ( char * )calloc ( 512, sizeof(*buf) );
4545
char *password = passwd.toLatin1().data();
46-
strncpy ( buf,password,strlen(password));
46+
memcpy( buf,password,strlen(password));
4747

4848
/*
4949
* The crypt_r function does the same thing as crypt, but takes an extra parameter which includes space for its result (among other things), so it can be reentrant. data->initialized must be cleared to zero before the first time crypt_r is called

sha512.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ char *sha512::encryptpass( QString passwd) const
3737

3838
char *buf = ( char * )calloc ( 512, sizeof(*buf) );
3939
char *password = passwd.toLatin1().data();
40-
strncpy ( buf,password,strlen(password));
40+
memcpy( buf,password,strlen(password));
4141

4242
/*
4343
* The crypt_r function does the same thing as crypt, but takes an extra parameter which includes space for its result (among other things), so it can be reentrant. data->initialized must be cleared to zero before the first time crypt_r is called

users.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,10 @@ QString emptystr = "";
286286
/* create the new gecos string */
287287
len =(strlen (pinfo->full_name) + strlen (pinfo->office) + strlen (pinfo->office_phone) + strlen (pinfo->home_phone) + 4);
288288
char *gecos =(char*)calloc(len, sizeof(char));
289-
int fname = sizeof(pinfo->full_name);
289+
int fname = strlen(pinfo->full_name);
290290

291291
if (pinfo->full_name == emptystr.toLatin1().data() && pinfo->office == emptystr.toLatin1().data() && pinfo->office_phone == emptystr.toLatin1().data() && pinfo->home_phone == emptystr.toLatin1().data())
292292
strncpy(gecos, emptystr.toLatin1().data(), fname);
293-
//gecos = emptystr.toLatin1().data();
294293

295294
else
296295
{

0 commit comments

Comments
 (0)