Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 1 | From 8321f8b3befbaa355cfed988fdd8494133989676 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Mon, 4 Feb 2019 00:38:16 -0800 |
| 4 | Subject: [PATCH] hook: Do not append int to std::string |
| 5 | |
| 6 | Clang find this error |
| 7 | |
| 8 | | ../../../git/sysdeps/linux-gnu/hooks.c:205:51: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus |
| 9 | -int] |
| 10 | | || sprintf(syspath, "%s/%s", sysconfdir, FN + 1) < 0) |
| 11 | | ~~~^~~ |
| 12 | |
| 13 | Upstream-Status: Pending |
| 14 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 15 | --- |
| 16 | sysdeps/linux-gnu/hooks.c | 2 +- |
| 17 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 18 | |
| 19 | --- a/sysdeps/linux-gnu/hooks.c |
| 20 | +++ b/sysdeps/linux-gnu/hooks.c |
| 21 | @@ -200,9 +200,10 @@ os_get_ltrace_conf_filenames(struct vect |
| 22 | const char *sysconfdir = SYSCONFDIR; |
| 23 | if (sysconfdir != NULL && *sysconfdir != '\0') { |
| 24 | /* No +1, we skip the initial period. */ |
| 25 | - syspath = malloc(strlen(sysconfdir) + sizeof FN); |
| 26 | + syspath = malloc(strlen(sysconfdir) + sizeof FN + 1); |
| 27 | + syspath[strlen(sysconfdir) + sizeof FN + 1] = '\0'; |
| 28 | if (syspath == NULL |
| 29 | - || sprintf(syspath, "%s/%s", sysconfdir, FN + 1) < 0) |
| 30 | + || sprintf(syspath, "%s/%s", sysconfdir, FN) < 0) |
| 31 | goto fail; |
| 32 | } |
| 33 | |