Skip to content

Commit 6f677d5

Browse files
committed
GCC 10.3: Wformat-overflow
Spotted buffer overflows in `sprintf` with GCC 10.3
1 parent 0de9fb3 commit 6f677d5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Dataset.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,14 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr,
431431
XmStringFree(sNewLevel);
432432

433433
sprintf(minInfoV, fstring, rMin);
434+
// warning: '%s' directive writing up to 159 bytes into a region of size 156 [-Wformat-overflow=]
434435
sprintf(minInfo, "Min:%s", minInfoV);
435436
XmString sNewMin = XmStringCreateSimple(minInfo);
436437
XtVaSetValues(wMinValue, XmNlabelString, sNewMin, NULL);
437438
XmStringFree(sNewMin);
438439

439440
sprintf(maxInfoV, fstring, rMax);
441+
// warning: '%s' directive writing up to 159 bytes into a region of size 156 [-Wformat-overflow=]
440442
sprintf(maxInfo, "Max:%s", maxInfoV);
441443
XmString sNewMax = XmStringCreateSimple(maxInfo);
442444
XtVaSetValues(wMaxValue, XmNlabelString, sNewMax, NULL);

PltApp.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,6 +2832,7 @@ void PltApp::DoSetRangeButton(Widget, XtPointer, XtPointer) {
28322832
rtMin, rtMax);
28332833
sprintf(fMin, format, rtMin);
28342834
sprintf(fMax, format, rtMax);
2835+
// warning: '%s' directive writing up to 159 bytes into a region of size 155 [-Wformat-overflow=]
28352836
sprintf(range, "Min: %s Max: %s", fMin, fMax);
28362837
strcpy(saveRangeString, range);
28372838

@@ -2964,9 +2965,11 @@ void PltApp::DoSetRangeButton(Widget, XtPointer, XtPointer) {
29642965
pltAppState->CurrentDerivedNumber(), rtMin, rtMax);
29652966
sprintf(fMin, format, rtMin);
29662967
sprintf(fMax, format, rtMax);
2968+
// warning: '%s' directive writing up to 159 bytes into a region of size 155 [-Wformat-overflow=]
29672969
sprintf(range, "Min: %s", fMin);
29682970
XtVaCreateManagedWidget(range, xmLabelGadgetClass, wRangeRC, NULL);
29692971
//XtVaSetValues(wid, XmNleftOffset, 20, NULL);
2972+
// warning: '%s' directive writing up to 159 bytes into a region of size 155 [-Wformat-overflow=]
29702973
sprintf(range, "Max: %s", fMax);
29712974
XtVaCreateManagedWidget(range, xmLabelGadgetClass, wRangeRC, NULL);
29722975

@@ -2975,8 +2978,10 @@ void PltApp::DoSetRangeButton(Widget, XtPointer, XtPointer) {
29752978
rtMin, rtMax);
29762979
sprintf(fMin, format, rtMin);
29772980
sprintf(fMax, format, rtMax);
2981+
// warning: '%s' directive writing up to 159 bytes into a region of size 155 [-Wformat-overflow=]
29782982
sprintf(range, "Min: %s", fMin);
29792983
XtVaCreateManagedWidget(range, xmLabelGadgetClass, wRangeRC, NULL);
2984+
// warning: '%s' directive writing up to 159 bytes into a region of size 155 [-Wformat-overflow=]
29802985
sprintf(range, "Max: %s", fMax);
29812986
XtVaCreateManagedWidget(range, xmLabelGadgetClass, wRangeRC, NULL);
29822987

0 commit comments

Comments
 (0)