Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply most patches in chw's repository #26

Merged
merged 8 commits into from
Aug 16, 2024
Merged

Conversation

mxmanghi
Copy link
Contributor

@mxmanghi mxmanghi commented Aug 13, 2024

I applied to the current FA code for tclcurl the changes made in androwish's repository (https://www.androwish.org/index.html/tktview/b7f1f6c72d7026ef04b7e77b687de25a7cc836d7). I also reworked the curlWriteProcInvoke function that caused Tcl to segfault (!) when the call back definition was made by multiple words, like in the case where the callback is implemented by an object method.

@mxmanghi mxmanghi closed this Aug 13, 2024
@resuna
Copy link
Member

resuna commented Aug 13, 2024

Why was this closed?

@mxmanghi
Copy link
Contributor Author

mxmanghi commented Aug 13, 2024 via email

@mxmanghi mxmanghi reopened this Aug 13, 2024
@resuna
Copy link
Member

resuna commented Aug 13, 2024

Thank you!

@resuna
Copy link
Member

resuna commented Aug 13, 2024

Looks like it would benefit from having enums matching the method/option lists in tclcurl.h, it would make tclcurl.c easier to follow. :)

@bovine
Copy link
Member

bovine commented Aug 13, 2024

Do you have a test case that can reproduce the crash?

@mxmanghi
Copy link
Contributor Author

mxmanghi commented Aug 13, 2024 via email

@mxmanghi
Copy link
Contributor Author

mxmanghi commented Aug 13, 2024

Do you have a test case that can reproduce the crash?

I have 3 cases. They have been tested on Ubuntu Noble, but also with a custom installation of Tcl 8.6.14 with optimizer disabled and symbols loaded

1)
tclsh8.6 [~/Documents/tclcurl] package require TclCurl
7.22.0
tclsh8.6 [~/Documents/tclcurl] set curl [::curl::init]
curl1
tclsh8.6 [~/Documents/tclcurl] $curl configure -url https://centromajorana.it/ -header 1 -timeout 5000 -writeproc [namespace current]::invalidproc
tclsh8.6 [~/Documents/tclcurl] $curl perform
Segmentation fault (core dumped)

2)
tclsh8.6 [~/Documents/tclcurl] package require TclCurl
7.22.0
tclsh8.6 [~/Documents/tclcurl] set curl [::curl::init]
curl1
tclsh8.6 [~/Documents/tclcurl] ::oo::class create CurlHandler
::CurlHandler
tclsh8.6 [~/Documents/tclcurl] ::oo::define CurlHandler { method callback {s} { puts $s } }
tclsh8.6 [~/Documents/tclcurl] set ch [CurlHandler new]
tclsh8.6 [~/Documents/tclcurl] $curl configure -url https://centromajorana.it/ -header 1 -timeout 5000 -writeproc [list $ch callback]
tclsh8.6 [~/Documents/tclcurl] $curl perform
Segmentation fault (core dumped)

3)
tclsh8.6 [~/Documents/tclcurl] package require TclCurl
7.22.0
tclsh8.6 [~/Documents/tclcurl] proc callback {s} { puts [string length $s] }
tclsh8.6 [~/Documents/tclcurl] set curl [::curl::init]
curl1
tclsh8.6 [~/Documents/tclcurl] $curl configure -url https://centromajorana.it/ -header 1 -timeout 5000 -writeproc callback
tclsh8.6 [~/Documents/tclcurl] $curl perform
17
37
32
67
23
28
40
2
7940
1663
0
tclsh8.6 [~/Documents/tclcurl] 

@bovine
Copy link
Member

bovine commented Aug 13, 2024

If you sync your branch with our master, the broken CI builds should be fixed here too.

@bovine
Copy link
Member

bovine commented Aug 13, 2024

the Mac CI is legitimately failing on something involving SetoptBlob not being defined.

In the curlVersionInfo function, the tmp[7] variable can be removed since its only use was eliminated by the use of Tcl_ObjPrintf in the case 1 block.

There are a couple of other warnings as well.

@bovine bovine linked an issue Aug 13, 2024 that may be closed by this pull request
@mxmanghi mxmanghi marked this pull request as ready for review August 14, 2024 01:02
Copy link
Member

@bovine bovine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like fine improvements. I've suggested a couple of places where snprintf could be used during the handle generation.

@resuna might want to review the entire PR also.

generic/tclcurl.c Outdated Show resolved Hide resolved
generic/tclcurl.c Outdated Show resolved Hide resolved
snprintf(tclCommand,500,"%s %s %s",curlData->fnmatchProc,pattern,filename);
tclProcPtr=Tcl_NewStringObj(tclCommand,-1);

tclProcPtr=Tcl_ObjPrintf("%s %s %s",curlData->fnmatchProc,pattern,filename);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be built up as a list? What if pattern contains spaces?

"-ftpsslauth", "-sourceurl", "-sourcequote",
"-ftpaccount", "-ignorecontentlength",
"-cookielist", "-ftpskippasvip",
"-ftpfilemethod", "-localport", "-localportrange",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was anything actually changed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's easy to verify that the 2 option lists are just reorganized

int curlShareInitObjCmd (ClientData clientData, Tcl_Interp *interp,
int objc,Tcl_Obj *CONST objv[]);
int curlShareObjCmd (ClientData clientData, Tcl_Interp *interp,
int objc,Tcl_Obj *CONST objv[]);
int curlCleanUpShareCmd(ClientData clientData);

#ifndef multi_h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any possibility that multi_h won't be set? multi.c (and thus multi.h) seem to be incorporated unconditionally in the config files.

@mxmanghi
Copy link
Contributor Author

I applied the last change suggested by Jeff. What is your policy for releasing? Is it worth a release? I'm making out of the whole stuff a package for Debian/Ubuntu, I can apply the new improvements as patches for the Debian packaging system but I rather prefer to release as is with a new patchlevel number

@bovine
Copy link
Member

bovine commented Aug 15, 2024

after we merge this PR, we might want to also get PR 22 (I suspect there will be some minor merge conflicts), and then tag a new release.

@bovine bovine merged commit 26edf70 into flightaware:master Aug 16, 2024
3 checks passed
@bovine
Copy link
Member

bovine commented Aug 16, 2024

I've tagged v7.22.1 and left that other PR unmerged for now. It can be addressed in the future.

@mxmanghi
Copy link
Contributor Author

Great! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TclCurl curl::versioninfo core dump, buffer overflow in curlVersion()
3 participants