From 664200e644b45e52c70affa1c036d7366474ae9d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 19 Aug 2013 19:04:33 +0000 Subject: core *printf patch git-svn-id: http://svn.miranda-ng.org/main/trunk@5750 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stdmsg/src/msglog.cpp | 17 +++++++++-------- src/core/stdmsg/src/msgs.cpp | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/core/stdmsg') diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index f2c82f8a9f..53f1ef7582 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -143,7 +143,7 @@ static int AppendToBufferWithRTF(char **buffer, int *cbBufferEnd, int *cbBufferA { *tag = 0; *tage = 0; - d += sprintf(d, "{\\field{\\*\\fldinst HYPERLINK \"%s\"}{\\fldrslt %s}}", mir_t2a(tagu), mir_t2a(tag + 1)); + d += sprintf(d, "{\\field{\\*\\fldinst HYPERLINK \"%s\"}{\\fldrslt %s}}", mir_t2a(tagu), mir_t2a(tag + 1)); //!!!!!!!!!! line = tage + 5; found = 1; } @@ -167,11 +167,11 @@ static int AppendToBufferWithRTF(char **buffer, int *cbBufferEnd, int *cbBufferA if (!found) { if (*line < 128) *d++ = (char) *line; - else d += sprintf(d, "\\u%d ?", *line); + else d += sprintf(d, "\\u%d ?", *line); //!!!!!!!!!! } } else if (*line < 128) *d++ = (char) *line; - else d += sprintf(d, "\\u%d ?", *line); + else d += sprintf(d, "\\u%d ?", *line); //!!!!!!!!!! } *(d++) = '}'; @@ -239,7 +239,7 @@ static char *SetToStyle(int style) LOGFONT lf; LoadMsgDlgFont(style, &lf, NULL); - wsprintfA(szStyle, "\\f%u\\cf%u\\b%d\\i%d\\fs%u", style, style, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY); + mir_snprintf(szStyle, SIZEOF(szStyle), "\\f%u\\cf%u\\b%d\\i%d\\fs%u", style, style, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY); return szStyle; } @@ -606,9 +606,10 @@ void LoadMsgLogIcons(void) for (i = 0; i < SIZEOF(pLogIconBmpBits); i++) { hIcon = Skin_GetIconByHandle(iconList[i].hIcolib); - pLogIconBmpBits[i] = (PBYTE) mir_alloc(RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2); + size_t size = RTFPICTHEADERMAXSIZE + (bih.biSize + widthBytes * bih.biHeight) * 2; + pLogIconBmpBits[i] = (PBYTE) mir_alloc(size); //I can't seem to get binary mode working. No matter. - rtfHeaderSize = sprintf((char*)pLogIconBmpBits[i], "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight); + rtfHeaderSize = mir_snprintf((char*)pLogIconBmpBits[i], size, "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight); hoBmp = (HBITMAP) SelectObject(hdcMem, hBmp); FillRect(hdcMem, &rc, hBkgBrush); DrawIconEx(hdcMem, 0, 0, hIcon, bih.biWidth, bih.biHeight, 0, NULL, DI_NORMAL); @@ -619,9 +620,9 @@ void LoadMsgLogIcons(void) { int n; for (n = 0; n < sizeof(BITMAPINFOHEADER); n++) - sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]); + sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + n * 2, "%02X", ((PBYTE) & bih)[n]); //!!!!!!!!!!!!! for (n = 0; n < widthBytes * bih.biHeight; n += 4) - sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); + sprintf((char*)pLogIconBmpBits[i] + rtfHeaderSize + (bih.biSize + n) * 2, "%02X%02X%02X%02X", pBmpBits[n], pBmpBits[n + 1], pBmpBits[n + 2], pBmpBits[n + 3]); //!!!!!!!!!!!!! } logIconBmpSize[i] = rtfHeaderSize + (bih.biSize + widthBytes * bih.biHeight) * 2 + 1; pLogIconBmpBits[i][logIconBmpSize[i] - 1] = '}'; diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 016dcdc765..b8c1298ad8 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -516,7 +516,7 @@ STDMETHODIMP CREOleCallback::GetNewStorage(LPSTORAGE * lplpstg) { WCHAR szwName[64]; char szName[64]; - wsprintfA(szName, "s%u", nextStgId++); + mir_snprintf(szName, SIZEOF(szName), "s%u", nextStgId++); MultiByteToWideChar(CP_ACP, 0, szName, -1, szwName, SIZEOF(szwName)); if (pictStg == NULL) return STG_E_MEDIUMFULL; -- cgit v1.2.3