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

scheduler/ipp.c create_local_bg_thread function set printer->device_uri to local variable address. #419

Closed
jiaojinxing opened this issue Jun 21, 2022 · 6 comments · Fixed by #420
Assignees
Labels
bug Something isn't working priority-high
Milestone

Comments

@jiaojinxing
Copy link

Line 5300:

  if (strstr(printer->device_uri, "._tcp"))
  {
    cupsdLogMessage(CUPSD_LOG_DEBUG2, "%s: Resolving mDNS URI \"%s\".", printer->name, printer->device_uri);

    if (!_httpResolveURI(printer->device_uri, uri, sizeof(uri), _HTTP_RESOLVE_DEFAULT, NULL, NULL))
    {
      cupsdLogMessage(CUPSD_LOG_ERROR, "%s: Couldn't resolve mDNS URI \"%s\".", printer->name, printer->device_uri);
      return (NULL);
    }

    cupsdSetString(&printer->device_uri, uri); // Fixed printer->device_uri = uri;
  }
@michaelrsweet michaelrsweet self-assigned this Jun 21, 2022
@michaelrsweet michaelrsweet added bug Something isn't working priority-high labels Jun 21, 2022
@michaelrsweet michaelrsweet added this to the v2.4.3 milestone Jun 21, 2022
@michaelrsweet
Copy link
Member

Yes, this needs to be fixed...

@zdohnal
Copy link
Member

zdohnal commented Jun 22, 2022

(facepalm) I'm sorry for this elementary mistake - @michaelrsweet if you don't mind, I'll fix this since I made that mistake.

zdohnal added a commit to zdohnal/cups that referenced this issue Jun 22, 2022
If a driverless printer has .local in its URI, we resolve the
URI and save the resolved one as new device URI. The problem was that
a local pointer was assigned to the structure which is passed to the
function as parameter, so the pointer became invalid once the execution
left the create_local_bg_thread() function.

We need to allocate the device URI via cupsdSetString() - the string is
then freed when the printer is deleted or cupsd shuts down.

Fixes OpenPrinting#419.
@zdohnal
Copy link
Member

zdohnal commented Jun 22, 2022

I've created PR for the issue - I didn't want to be impolite to push the change when you assigned yourself to the issue.

@michaelrsweet
Copy link
Member

@zdohnal Go for it! :)

@zdohnal
Copy link
Member

zdohnal commented Jun 23, 2022

@jiaojinxing thank you for the patch and letting us know!

@jiaojinxing
Copy link
Author

@zdohnal No thanks, I'm porting cups to EdgerOS(our intelligent edge operating system), and found the issue during testing, thanks for developing the cups project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants