mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Fix gcc/9.3.1 and gcc/10.2.1 errors and warnings
This commit is contained in:
18
input.c
18
input.c
@@ -442,7 +442,23 @@ homeexpand(char *name)
|
||||
if (fullpath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strncpy(fullpath, ent->pw_dir, fullpath_len+1);
|
||||
/*
|
||||
* The next statement could be:
|
||||
*
|
||||
* strncpy(fullpath, ent->pw_dir, fullpath_len);
|
||||
*
|
||||
* however compilers like gcc would issue warnings
|
||||
* such as:
|
||||
*
|
||||
* specified bound depends on the length of the
|
||||
* source argument
|
||||
*
|
||||
* even though we terminate the string by setting a NUL
|
||||
* byte following the copy. Therefore we call memcpy()
|
||||
* instead to avoid such warnings.
|
||||
*/
|
||||
memcpy(fullpath, ent->pw_dir, fullpath_len);
|
||||
fullpath[fullpath_len] = '\0';
|
||||
return fullpath;
|
||||
}
|
||||
username = (char *) malloc(after-name + 1 + 1);
|
||||
|
Reference in New Issue
Block a user