• Stephan Bergmann's avatar
    Avoid overflow with large row heights · d4dd0732
    Stephan Bergmann yazdı
    With -fsanitize=float-cast-overflow, opening csv/fdo54919-3.csv as obtained by
    bin/get-bugzilla-attachments-by-mimetype (i.e., the attachment at
    <https://bugs.documentfoundation.org/show_bug.cgi?id=54919#c2>) fails first with
    
    > sc/source/core/data/column2.cxx:942:75: runtime error: 73940.3 is outside the range of representable values of type 'unsigned short'
    >  #0 in ScColumn::GetOptimalHeight(sc::RowHeightContext&, int, int, unsigned short, int) at sc/source/core/data/column2.cxx:942:75 (instdir/program/../program/libsclo.so +0xc93bfaf)
    >  #1 in (anonymous namespace)::GetOptimalHeightsInColumn(sc::RowHeightContext&, ScColContainer&, int, int, ScProgress*, unsigned long) at sc/source/core/data/table1.cxx:114:20 (instdir/program/../program/libsclo.so +0xe02fd57)
    >  #2 in ScTable::SetOptimalHeight(sc::RowHeightContext&, int, int, ScProgress*, unsigned long) at sc/source/core/data/table1.cxx:466:5 (instdir/program/../program/libsclo.so +0xe02ec69)
    >  #3 in ScDocument::SetOptimalHeight(sc::RowHeightContext&, int, int, short) at sc/source/core/data/document.cxx:4267:18 (instdir/program/../program/libsclo.so +0xd18bc12)
    >  #4 in ScDocShell::AdjustRowHeight(int, int, short) at sc/source/ui/docshell/docsh5.cxx:411:32 (instdir/program/../program/libsclo.so +0x111eb5c6)
    >  #5 in ScImportExport::ExtText2Doc(SvStream&) at sc/source/ui/docshell/impex.cxx:1469:29 (instdir/program/../program/libsclo.so +0x11498773)
    >  #6 in ScImportExport::ImportStream(SvStream&, rtl::OUString const&, SotClipboardFormatId) at sc/source/ui/docshell/impex.cxx:379:13 (instdir/program/../program/libsclo.so +0x11492715)
    >  #7 in ScDocShell::ConvertFrom(SfxMedium&) at sc/source/ui/docshell/docsh.cxx:1299:35 (instdir/program/../program/libsclo.so +0x110b0cee)
    >  #8 in SfxObjectShell::DoLoad(SfxMedium*) at sfx2/source/doc/objstor.cxx:768:23 (instdir/program/libsfxlo.so +0x49d934a)
    [...]
    
    and then with
    
    > sc/source/core/data/fillinfo.cxx:216:59: runtime error: 113431 is outside the range of representable values of type 'unsigned short'
    >  #0 in (anonymous namespace)::initRowInfo(ScDocument const*, RowInfo*, unsigned long, double, int, short, int&, unsigned long&, int&) at sc/source/core/data/fillinfo.cxx:216:59 (instdir/program/../program/libsclo.so +0xdb8ebcf)
    >  #1 in ScDocument::FillInfo(ScTableInfo&, short, int, short, int, short, double, double, bool, bool, ScMarkData const*) at sc/source/core/data/fillinfo.cxx:401:5 (instdir/program/../program/libsclo.so +0xdb7896e)
    >  #2 in ScPrintFunc::DrawToDev(ScDocument*, OutputDevice*, double, tools::Rectangle const&, ScViewData*, bool) at sc/source/ui/view/printfun.cxx:544:11 (instdir/program/../program/libsclo.so +0x1309d461)
    >  #3 in ScDocShell::Draw(OutputDevice*, JobSetup const&, unsigned short) at sc/source/ui/docshell/docsh4.cxx:2036:9 (instdir/program/../program/libsclo.so +0x111aabd7)
    >  #4 in SfxObjectShell::DoDraw_Impl(OutputDevice*, Point const&, Fraction const&, Fraction const&, JobSetup const&, unsigned short) at sfx2/source/doc/objembed.cxx:229:5 (instdir/program/libsfxlo.so +0x491e953)
    >  #5 in SfxObjectShell::DoDraw(OutputDevice*, Point const&, Size const&, JobSetup const&, unsigned short) at sfx2/source/doc/objembed.cxx:176:9 (instdir/program/libsfxlo.so +0x491cbb3)
    >  #6 in SfxObjectShell::CreatePreviewMetaFile_Impl(bool) const at sfx2/source/doc/objcont.cxx:171:40 (instdir/program/libsfxlo.so +0x48ffc5a)
    >  #7 in SfxObjectShell::GetPreviewMetaFile(bool) const at sfx2/source/doc/objcont.cxx:118:12 (instdir/program/libsfxlo.so +0x48fdc15)
    >  #8 in SfxPickListImpl::AddDocumentToPickList(SfxObjectShell*) at sfx2/source/appl/sfxpicklist.cxx:135:62 (instdir/program/libsfxlo.so +0x361c3e5)
    [...]
    
    These are similar to <https://gerrit.libreoffice.org/#/c/73267/> "Avoid overflow
    when scaling column width" and <https://gerrit.libreoffice.org/#/c/73273/>
    "Avoid overflow in ScColumn::GetOptimalColWidth", respectively, for column width
    calculations, and given csv/fdo54919-3.csv has a rather tall fifth row, these
    values do not look completely implausible---which of course begs the question
    whether sal_uInt16 is an appropriate data type here.
    
    But assuming sal_uInt16 is a useful choice, just clamp the calculated heights
    accordingly.  (Using std::clamp, we can get rid of the following lines in
    initRowInfo that ensure nHeight >= 1.)
    
    Change-Id: I99f97c1dedcd8c6d2daa63f2e10011a3ce837fe4
    Reviewed-on: https://gerrit.libreoffice.org/73278
    Tested-by: Jenkins
    Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
    d4dd0732
Adı
Son kayıt (commit)
Son güncelleme
..
inc Loading commit data...
qa Loading commit data...
res/xml Loading commit data...
sdi Loading commit data...
source Loading commit data...
uiconfig/scalc Loading commit data...
util Loading commit data...
workben Loading commit data...
AllLangMoTarget_sc.mk Loading commit data...
CppunitTest_sc_addin_functions_test.mk Loading commit data...
CppunitTest_sc_anchor_test.mk Loading commit data...
CppunitTest_sc_annotationobj.mk Loading commit data...
CppunitTest_sc_annotationshapeobj.mk Loading commit data...
CppunitTest_sc_annotationsobj.mk Loading commit data...
CppunitTest_sc_arealinkobj.mk Loading commit data...
CppunitTest_sc_arealinksobj.mk Loading commit data...
CppunitTest_sc_array_functions_test.mk Loading commit data...
CppunitTest_sc_autoformatobj.mk Loading commit data...
CppunitTest_sc_autoformatsobj.mk Loading commit data...
CppunitTest_sc_bugfix_test.mk Loading commit data...
CppunitTest_sc_cache_test.mk Loading commit data...
CppunitTest_sc_cellcursorobj.mk Loading commit data...
CppunitTest_sc_cellfieldsobj.mk Loading commit data...
CppunitTest_sc_cellformatsenumeration.mk Loading commit data...
CppunitTest_sc_cellformatsobj.mk Loading commit data...
CppunitTest_sc_cellobj.mk Loading commit data...
CppunitTest_sc_cellrangeobj.mk Loading commit data...
CppunitTest_sc_cellrangesobj.mk Loading commit data...
CppunitTest_sc_cellsearchobj.mk Loading commit data...
CppunitTest_sc_cellsenumeration.mk Loading commit data...
CppunitTest_sc_cellsobj.mk Loading commit data...
CppunitTest_sc_chart2dataprovider.mk Loading commit data...
CppunitTest_sc_chart_regression_test.mk Loading commit data...
CppunitTest_sc_chartobj.mk Loading commit data...
CppunitTest_sc_chartsobj.mk Loading commit data...
CppunitTest_sc_check_data_pilot_field.mk Loading commit data...
CppunitTest_sc_check_data_pilot_table.mk Loading commit data...
CppunitTest_sc_check_xcell_ranges_query.mk Loading commit data...
CppunitTest_sc_cond_format_merge.mk Loading commit data...
CppunitTest_sc_consolidationdescriptorobj.mk Loading commit data...
CppunitTest_sc_copypaste.mk Loading commit data...
CppunitTest_sc_core.mk Loading commit data...
CppunitTest_sc_database_functions_test.mk Loading commit data...
CppunitTest_sc_databaserangeobj.mk Loading commit data...
CppunitTest_sc_databaserangesobj.mk Loading commit data...
CppunitTest_sc_datapilotfieldgroupitemobj.mk Loading commit data...
CppunitTest_sc_datapilotfieldgroupobj.mk Loading commit data...
CppunitTest_sc_datapilotfieldgroupsobj.mk Loading commit data...
CppunitTest_sc_datapilotfieldobj.mk Loading commit data...
CppunitTest_sc_datapilotfieldsobj.mk Loading commit data...
CppunitTest_sc_datapilotitemobj.mk Loading commit data...
CppunitTest_sc_datapilotitemsobj.mk Loading commit data...
CppunitTest_sc_datapilottableobj.mk Loading commit data...
CppunitTest_sc_datapilottablesobj.mk Loading commit data...
CppunitTest_sc_dataprovider.mk Loading commit data...
CppunitTest_sc_datatransformation.mk Loading commit data...
CppunitTest_sc_datetime_functions_test.mk Loading commit data...
CppunitTest_sc_ddelinkobj.mk Loading commit data...
CppunitTest_sc_ddelinksobj.mk Loading commit data...
CppunitTest_sc_documentconfigurationobj.mk Loading commit data...
CppunitTest_sc_drawpageobj.mk Loading commit data...
CppunitTest_sc_drawpagesobj.mk Loading commit data...
CppunitTest_sc_editfieldobj_cell.mk Loading commit data...
CppunitTest_sc_editfieldobj_header.mk Loading commit data...
CppunitTest_sc_filterdescriptorbase.mk Loading commit data...
CppunitTest_sc_filters_test.mk Loading commit data...
CppunitTest_sc_financial_functions_test.mk Loading commit data...
CppunitTest_sc_functiondescriptionobj.mk Loading commit data...
CppunitTest_sc_functionlistobj.mk Loading commit data...
CppunitTest_sc_functions_test_old.mk Loading commit data...
CppunitTest_sc_headerfieldsobj.mk Loading commit data...
CppunitTest_sc_headerfootercontentobj.mk Loading commit data...
CppunitTest_sc_html_export_test.mk Loading commit data...
CppunitTest_sc_importdescriptorbaseobj.mk Loading commit data...
CppunitTest_sc_indexenumeration_cellannotationsenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_cellarealinksenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_databaserangesenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_datapilotfieldsenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_datapilotitemsenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_datapilottablesenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_ddelinksenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_functiondescriptionenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_labelrangesenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_namedrangesenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_scenariosenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_sheetcellrangesenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_sheetlinksenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_spreadsheetsenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_spreadsheetviewpanesenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_subtotalfieldsenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_tableautoformatenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_tablechartsenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_tablecolumnsenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_tableconditionalentryenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_tablerowsenumeration.mk Loading commit data...
CppunitTest_sc_indexenumeration_textfieldenumeration.mk Loading commit data...
CppunitTest_sc_information_functions_test.mk Loading commit data...
CppunitTest_sc_labelrangeobj.mk Loading commit data...
CppunitTest_sc_labelrangesobj.mk Loading commit data...
CppunitTest_sc_logical_functions_test.mk Loading commit data...
CppunitTest_sc_macros_test.mk Loading commit data...
CppunitTest_sc_mark_test.mk Loading commit data...
CppunitTest_sc_mathematical_functions_test.mk Loading commit data...
CppunitTest_sc_modelobj.mk Loading commit data...
CppunitTest_sc_namedrangeobj.mk Loading commit data...
CppunitTest_sc_namedrangesobj.mk Loading commit data...
CppunitTest_sc_new_cond_format_api.mk Loading commit data...
CppunitTest_sc_opencl_test.mk Loading commit data...
CppunitTest_sc_outlineobj.mk Loading commit data...
CppunitTest_sc_parallelism.mk Loading commit data...
CppunitTest_sc_pdf_export.mk Loading commit data...
CppunitTest_sc_perfobj.mk Loading commit data...
CppunitTest_sc_pivottable_filters_test.mk Loading commit data...
CppunitTest_sc_range_test.mk Loading commit data...
CppunitTest_sc_rangelst_test.mk Loading commit data...
CppunitTest_sc_recentfunctionsobj.mk Loading commit data...
CppunitTest_sc_recordchanges.mk Loading commit data...
CppunitTest_sc_scenariosobj.mk Loading commit data...
CppunitTest_sc_screenshots.mk Loading commit data...
CppunitTest_sc_shapeobj.mk Loading commit data...
CppunitTest_sc_sheetlinkobj.mk Loading commit data...
CppunitTest_sc_sheetlinksobj.mk Loading commit data...
CppunitTest_sc_sortdescriptorbaseobj.mk Loading commit data...
CppunitTest_sc_spreadsheet_functions_test.mk Loading commit data...
CppunitTest_sc_spreadsheetsettings.mk Loading commit data...
CppunitTest_sc_spreadsheetsettingsobj.mk Loading commit data...
CppunitTest_sc_statistical_functions_test.mk Loading commit data...
CppunitTest_sc_stylefamiliesobj.mk Loading commit data...
CppunitTest_sc_stylefamilyobj.mk Loading commit data...
CppunitTest_sc_subsequent_export_test.mk Loading commit data...
CppunitTest_sc_subsequent_filters_test.mk Loading commit data...
CppunitTest_sc_subtotaldescriptorbase.mk Loading commit data...
CppunitTest_sc_subtotalfieldobj.mk Loading commit data...
CppunitTest_sc_tablecolumnobj.mk Loading commit data...
CppunitTest_sc_tablecolumnsobj.mk Loading commit data...
CppunitTest_sc_tableconditionalentryobj.mk Loading commit data...
CppunitTest_sc_tableconditionalformat.mk Loading commit data...
CppunitTest_sc_tablerowobj.mk Loading commit data...
CppunitTest_sc_tablerowsobj.mk Loading commit data...
CppunitTest_sc_tablesheetobj.mk Loading commit data...
CppunitTest_sc_tablesheetsobj.mk Loading commit data...
CppunitTest_sc_tablevalidationobj.mk Loading commit data...
CppunitTest_sc_tabviewobj.mk Loading commit data...
CppunitTest_sc_text_functions_test.mk Loading commit data...
CppunitTest_sc_tiledrendering.mk Loading commit data...
CppunitTest_sc_ucalc.mk Loading commit data...
CppunitTest_sc_uniquecellformatsenumeration.mk Loading commit data...
CppunitTest_sc_uniquecellformatsobj.mk Loading commit data...
CppunitTest_sc_viewpaneobj.mk Loading commit data...
IwyuFilter_sc.yaml Loading commit data...
JunitTest_sc_complex.mk Loading commit data...
JunitTest_sc_unoapi_1.mk Loading commit data...
JunitTest_sc_unoapi_2.mk Loading commit data...
JunitTest_sc_unoapi_3.mk Loading commit data...
JunitTest_sc_unoapi_4.mk Loading commit data...
JunitTest_sc_unoapi_6.mk Loading commit data...
JunitTest_sc_unoapi_7.mk Loading commit data...
Library_sc.mk Loading commit data...
Library_scd.mk Loading commit data...
Library_scfilt.mk Loading commit data...
Library_scqahelper.mk Loading commit data...
Library_scui.mk Loading commit data...
Library_vbaobj.mk Loading commit data...
Makefile Loading commit data...
Module_sc.mk Loading commit data...
Package_opencl.mk Loading commit data...
Package_res_xml.mk Loading commit data...
PythonTest_sc_python.mk Loading commit data...
README Loading commit data...
TODO.performance Loading commit data...
UIConfig_scalc.mk Loading commit data...
UITest_autofilter.mk Loading commit data...
UITest_calc_tests.mk Loading commit data...
UITest_calc_tests2.mk Loading commit data...
UITest_calc_tests3.mk Loading commit data...
UITest_calc_tests4.mk Loading commit data...
UITest_calc_tests6.mk Loading commit data...
UITest_calc_tests7.mk Loading commit data...
UITest_calc_tests8.mk Loading commit data...
UITest_chart.mk Loading commit data...
UITest_conditional_format.mk Loading commit data...
UITest_goalSeek.mk Loading commit data...
UITest_hideShowSheet.mk Loading commit data...
UITest_hide_cols.mk Loading commit data...
UITest_inputLine.mk Loading commit data...
UITest_key_f4.mk Loading commit data...
UITest_options.mk Loading commit data...
UITest_pageFormat.mk Loading commit data...
UITest_protect.mk Loading commit data...
UITest_range_name.mk Loading commit data...
UITest_search_replace.mk Loading commit data...
UITest_signatureLine.mk Loading commit data...
UITest_solver.mk Loading commit data...
UITest_sort.mk Loading commit data...
UITest_statistics.mk Loading commit data...
UITest_textCase.mk Loading commit data...
UITest_validity.mk Loading commit data...
common_unoapi_tests.mk Loading commit data...