diff options
author | Dmitri Pal <dpal@redhat.com> | 2012-12-23 13:49:56 -0500 |
---|---|---|
committer | Ondrej Kos <okos@redhat.com> | 2013-01-24 08:34:40 +0100 |
commit | 833a46e384828be48c27898e755d6215eb5c4bb8 (patch) | |
tree | eaf34cd463381efc40991151d41d9deec295f704 /ini/ini_config_ut.c | |
parent | 57faa64667411a3d8eeeeff62b1e659a94ed29cf (diff) | |
download | ding-libs-833a46e384828be48c27898e755d6215eb5c4bb8.tar.gz ding-libs-833a46e384828be48c27898e755d6215eb5c4bb8.tar.xz ding-libs-833a46e384828be48c27898e755d6215eb5c4bb8.zip |
Replacing sprintf with snprintf
Replaced sprintf in the unit test.
Defined constants for sizes and used them.
Wrpapped lines where noticed that they are longer than 80.
Added comments to the places where sprintf is still used
but it is safe to use.
Diffstat (limited to 'ini/ini_config_ut.c')
-rw-r--r-- | ini/ini_config_ut.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ini/ini_config_ut.c b/ini/ini_config_ut.c index 34b395b..fff3c4e 100644 --- a/ini/ini_config_ut.c +++ b/ini/ini_config_ut.c @@ -1547,6 +1547,7 @@ int main(int argc, char *argv[]) char *srcdir = NULL; char *rundir = NULL; const char inidir[] = "/ini"; + int len = 0; if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = 1; @@ -1555,14 +1556,15 @@ int main(int argc, char *argv[]) srcdir = getenv("srcdir"); if(srcdir) { - rundir = malloc(strlen(srcdir) + sizeof(inidir)); + len = strlen(srcdir) + sizeof(inidir); + rundir = malloc(len); if (!rundir) { printf("Failed to allocate memory to store path" " to the test files %d.\n", ENOMEM); return -1; } - sprintf(rundir, "%s%s", srcdir, inidir); + snprintf(rundir, len, "%s%s", srcdir, inidir); errno = 0; if(chdir(rundir) != 0) { |