History

zram: rework copy of compressor name in comp_algorithm_store()

comp_algorithm_store() passes the size of the source buffer to strlcpy() instead of the destination buffer size. Make it explicit that the two buffers have the same size and use strcpy() instead of strlcpy(). The latter can be done safely since the function ensures that the string in the source buffer is terminated.

Matthias Kaehlcke committed 9 years ago

Commit f357e341 parent aac2fea1 file · +2 −2Browse files

Unified · Split

drivers/block/zram/zram_drv.c+2−2
@@ -308,7 +308,7 @@ static ssize_t comp_algorithm_store(struct device *dev, · 307 unmodified lines
308 struct device_attribute *attr, const char *buf, size_t len)308 struct device_attribute *attr, const char *buf, size_t len)
309{309{
310 struct zram *zram = dev_to_zram(dev);310 struct zram *zram = dev_to_zram(dev);
311 char compressor[CRYPTO_MAX_ALG_NAME];311 char compressor[ARRAY_SIZE(zram->compressor)];
312 size_t sz;312 size_t sz;
313 313
314 strlcpy(compressor, buf, sizeof(compressor));314 strlcpy(compressor, buf, sizeof(compressor));
@@ -327,7 +327,7 @@ static ssize_t comp_algorithm_store(struct device *dev, · 12 unmodified lines
327 return -EBUSY;327 return -EBUSY;
328 }328 }
329 329
330 strlcpy(zram->compressor, compressor, sizeof(compressor));330 strcpy(zram->compressor, compressor);
331 up_write(&zram->init_lock);331 up_write(&zram->init_lock);
332 return len;332 return len;
333}333}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t