nano 2.5.3-2 on Xenial crashes with long paths on lockfiles

Bug #1641592 reported by Antti Tönkyrä on 2016-11-14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
nano (Ubuntu)
Brian Murray

Bug Description

# lsb_release -rd
Description: Ubuntu 16.04.1 LTS
Release: 16.04
# apt-cache policy nano
  Installed: 2.5.3-2
  Candidate: 2.5.3-2

1. # nano -G 999999999999999999999999999999999999999999999999999999999999999999999999999
2. <ctrl-z>
3. # nano -G 999999999999999999999999999999999999999999999999999999999999999999999999999
4. <answer y/n to the lockfile question>
5. <nano should segfault>

Quick dissection:
Looking at function do_lockfile in files.c, it seems that promptstr is statically allocated to 128 characters. Now with a sufficiently long filename, the following sprintf() call will overflow the allocated promptstr buffer and corrupt memory.

summary: - nano 2.5.3-2 on Xenial crashes when trying to access a lockfile
+ nano 2.5.3-2 on Xenial crashes with long paths on lockfiles

This is a duplicate of upstream bug .

The problem was fixed in git, commit fb9585e. See attached patch. The fix is in version 2.6.0 and higher.

Thanks for reporting.

The attachment "fixes the crash when finding lockfiles for long names" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Changed in nano (Ubuntu):
status: New → Triaged
importance: Undecided → High
Changed in nano (Ubuntu Xenial):
status: New → Triaged
importance: Undecided → High
Changed in nano (Ubuntu):
status: Triaged → Fix Released
Brian Murray (brian-murray) wrote :

I've uploaded this to the -proposed queue for review by the SRU team.

Changed in nano (Ubuntu Xenial):
assignee: nobody → Brian Murray (brian-murray)

Hello Antti, or anyone else affected,

Accepted nano into xenial-proposed. The package will build now and be available at in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at . Thank you in advance!

Changed in nano (Ubuntu Xenial):
status: Triaged → Fix Committed
tags: added: verification-needed
Antti Tönkyrä (atonkyra) wrote :
tags: added: verification-done
removed: verification-needed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package nano - 2.5.3-2ubuntu2

nano (2.5.3-2ubuntu2) xenial-proposed; urgency=medium

  * Apply upstream patch to allocate enough space for the prompt when finding
    a lock file. (LP: #1641592)

 -- Brian Murray <email address hidden> Tue, 14 Feb 2017 15:10:03 -0800

Changed in nano (Ubuntu Xenial):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for nano has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.